-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHw1prob14.java
More file actions
30 lines (24 loc) · 1.52 KB
/
Hw1prob14.java
File metadata and controls
30 lines (24 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//CSC110
//Professor Scheiman
//Jairo Molina
//Spring 2018
package hw1prob14;//DELETE THIS line if the program is not working.
import java.util.Scanner;//imports the java utility Scanner
public class Hw1prob14 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);//classifies Scanner utility under the variable scan.
double males;//creates variable type double
double females;//creates variable type double
System.out.println("Enter amount of males: ");//displays string
males = scan.nextDouble();//takes user input and stores it into variable males
System.out.println("Enter amount of females: ");//displays string
females = scan.nextDouble();//takes user input and stores it into variable females
double totalAll = males + females;//creates variable type double with result of an algorithm
double totalM = males / totalAll;//creates variable type double with result of an algorithm
double totalF = females / totalAll;//creates variable type double with result of an algorithm
System.out.println("There are "+males+" males in the classroom");///////////////////////////////////
System.out.println("There are "+females+" females in the classroom");/////////Final////////////////
System.out.println("The average of males is "+totalM+" or "+ totalM*100+"%");//Result/////////////
System.out.println("The average of female is "+totalF+" or "+ totalF*100+"%");///////////////////
}
}