Question: package stats_lab; import javax.swing.JOptionPane; public class stats_lab { public static void main(String[] args) { //declare variables String value,gender,more=Y; int female_count=0,male_count=0,age,male_average_age=0,female_average_age=0,male_age=0,female_age=0; double salary,female_salary=0,male_salary=0; double male_percent=0,female_percent=0; double
package stats_lab;
import javax.swing.JOptionPane;
public class stats_lab
{
public static void main(String[] args)
{
//declare variables
String value,gender,more="Y";
int female_count=0,male_count=0,age,male_average_age=0,female_average_age=0,male_age=0,female_age=0;
double salary,female_salary=0,male_salary=0;
double male_percent=0,female_percent=0;
double male_average_salary=0,female_average_salary=0;
double low_salary=1500000;
String low_gender="";
//add a loop to run until the user wants to stop
gender =JOptionPane.showInputDialog(null,"Enter the gender M for Male F for Female","Input Data",JOptionPane.QUESTION_MESSAGE);
value =JOptionPane.showInputDialog(null,"Enter age","Input Data",JOptionPane.QUESTION_MESSAGE);
age= Integer.parseInt(value);
value =JOptionPane.showInputDialog(null,"Enter the salary amount","Input Data",JOptionPane.QUESTION_MESSAGE);
salary= Double.parseDouble(value);
//count number of males and females
//total the salaries for both male and female
//total the ages for both male and female-needed for the average calculation
//keep track of the lowest salary and the gender having the lowest salary
//calculate average age
//calculate average salary
//calculate the percentage of total salary to males and females
//print all results
System.out.println("The count of males = "+male_count);
System.out.println("The count of females = "+female_count);
System.out.println("The average age of males = "+male_average_age);
System.out.println("The average age of females = "+female_average_age);
System.out.println("The total salary for males = "+male_salary);
System.out.println("The total salary for females = "+female_salary);
System.out.println("The average salary for males = "+male_average_salary);
System.out.println("The total salary for females = "+female_average_salary);
System.out.println("The percentage of the salary for males = "+male_percent);
System.out.println("The percentage of the salary for females = "+female_percent);
System.out.println("The gender with the lowest salalry = "+low_gender+" with a salary of "+low_salary);
System.exit(0);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
