grodek118

Male and Female Students Percentages

Aug 31st, 2022
1,073
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner keyboard = new Scanner(System.in);
  10.  
  11.         double maleStudents;
  12.         double femaleStudents;
  13.         double peopleInClass;
  14.         double malePercent;
  15.         double femalePercent;
  16.  
  17.         maleStudents = keyboard.nextInt();
  18.         femaleStudents = keyboard.nextInt();
  19.         peopleInClass = maleStudents + femaleStudents;
  20.  
  21.         malePercent = maleStudents / peopleInClass;
  22.         femalePercent = femaleStudents / peopleInClass;
  23.  
  24.         System.out.println("Students in class: " + peopleInClass);
  25.         System.out.println("Percent of male students: " + malePercent);
  26.         System.out.println("Percent of female students: " + femalePercent);
  27.  
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment