VED PROGRAMS BASED ON INPUT STRIES
In a class of 'n' number of students, the number of girls is 'm'.
Write a program to input the values of n and m. Find and print the
percentage of boys and girls in the class.
ind and display the percentage of boys and girls
java.io.*;
Answers
Answered by
5
Answer:
package collection;
import java.util.Scanner;
public class SwapNumber {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int m,n;
System.out.println("Enter no. of boys in class");
m=sc.nextInt();
System.out.println("Enter no. of girls in class");
n=sc.nextInt();
System.out.println("Percentage of boys in class: "+(double)m/(m+n)*100+"%");
System.out.println("Percentage of girls in class: "+(double)n/(m+n)*100+"%");
}
}
Output:
Enter no. of boys in class
50
Enter no. of girls in class
123
Percentage of boys in class: 28.901735%
Percentage of girls in class: 71.09826589595376%
Similar questions