In: Computer Science
Write a program that will input the information for 2 different employees. Prompt the user for the first employee’s name, hours worked and rate. Compute the salary and display it. Do the same for the second and third employees. Then, display a message to the effect that the highest salary is whatever and the lowest salary is whatever. When the program runs, the following should display information should line up just as I have it below. E:\> java Quiz4 Name:
John Doe Class: CSCI 1250-001 (or 002) Date: September 18, 2019 Program: Quiz4.java First Employee:
John Smith Hours Worked: 40.0 Rate of pay: 10.0 Salary for John Smith is $400.00
Second Employee:
Sarah Jones Hours worked: 30.0 Rate of pay: 7.50 Salary for Sarah Jones is $225.00
Third Employee: Andrew Johnson Hours Worked: 31.5 Rate of pay: 10.75 Salary for Andrew Johnson is $338.63
The largest salary is $400.00 The smallest salary is $225.00
import java.util.Scanner;
public class EmpInfo {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
System.out.println("Enter employee
name: ");
String name1 = sc.nextLine();
System.out.println("Enter hours
worked for emp1: ");
double hours1 =
sc.nextDouble();
System.out.println("Enter price for
emp1: ");
double price1 =
sc.nextDouble();
double salary1 = price1 *
hours1;
System.out.println(name1 + " Hours
Worked :" + hours1 + " Rate of pay: " + price1 + " Salary for " +
name1
+ " is $" + salary1);
//entering emp2 data
System.out.println("Enter employee
name2: ");
String name2 = sc.nextLine();
name2 = sc.nextLine();
System.out.println("Enter hours
worked for emp2: ");
double hours2 =
sc.nextDouble();
System.out.println("Enter price for
emp2: ");
double price2 =
sc.nextDouble();
double salary2 = price2 *
hours2;
System.out.println(name1 + " Hours
Worked :" + hours2 + " Rate of pay: " + price2 + " Salary for " +
name2
+ " is $" + salary2);
//entering emp3 data
System.out.println("Enter employee
name3: ");
String name3 = sc.nextLine();
name3 = sc.nextLine();
System.out.println("Enter hours
worked for emp3: ");
double hours3 =
sc.nextDouble();
System.out.println("Enter price for
emp3: ");
double price3 =
sc.nextDouble();
double salary3 = price3 *
hours3;
System.out.println(name3 + " Hours
Worked :" + hours3 + " Rate of pay: " + price3 + " Salary for " +
name3
+ " is $" + salary3);
double max, min;
//finding max salary
if (salary1 > salary2 &&
salary1 > salary3)
max =
salary1;
else if (salary2 >
salary3)
max =
salary2;
else
max =
salary3;
//finding min salary
if (salary1 < salary2 &&
salary1 < salary3)
min =
salary1;
else if (salary2 <
salary3)
min =
salary2;
else
min =
salary3;
//printing message
System.out.println("The largest
salary is $" + max + " The smallest salary is $" + min);
}
}
Note : If you like my answer please rate and help me it is very Imp for me