Answer to Question #265394 in Java | JSP | JSF for Jcarlo

Question #265394

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

1
Expert's answer
2021-11-13T23:51:10-0500
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);
 
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS