java create a program that asks the user for the number of male and female students registered in a class/section. the program should display the total number of students and the percentage of males and females in the class
import java.util.Scanner;
public class Main
{
public static void main (String args[])
{
Scanner input = new Scanner(System.in);
double Male;
double Female;
double total;
double Mpercentage, FPercentage;
System.out.println("Enter the number of male students: ");
Male = input.nextInt();
System.out.println("Enter the number of female students: ");
Female = input.nextInt();
total = Male + Female;
Mpercentage = ((Male / total)*100);
FPercentage = ((Female / total)*100);
System.out.println("Number of male students: " + Male);
System.out.println("Number of female students: " + Female);
System.out.println("Number of total students: " + total);
System.out.println("Percentage of male students: " + Mpercentage);
System.out.println("Percentage of female students: " + FPercentage);
}
}
Comments
Leave a comment