Question

In: Computer Science

Write a program that will input the information for 2 different employees. Prompt the user for...

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

Solutions

Expert Solution

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


Related Solutions

Write a program that calculates the salary of employees. The program should prompt the user to...
Write a program that calculates the salary of employees. The program should prompt the user to enter hourly rate and number of hours of work a day. Then, the program should display the salary daily, bi-weekly (5 days a week), and monthly. Sample program: Enter your hourly rate: >>> 20 Enter how many hours you work a day: >>> 8 Your daily salary is: $160 Your bi-weekly salary is: $1600 Your monthly: $3200
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the maximum number (as integer) Store a multiplication table for all combinations (with some specific eliminations) of value 0 through the maximum number (being entered) into a 2-D array Write a method named printTable to print out the MulitTable, with the following header, public static void printTable(int[][] multitable) In printTable(), when the value of the MultiTable is an odd number, print out Z Must use...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the number of Adult tickets to purchase Prompt user to input the number of Children tickets to purchase Prompt user to input the number of Senior tickets to purchase Write a method named, ticketCost(), which will be invoked by main() with statement similar to: cost = ticketCost( adults, children, senior ); Ticket costs structure: $15.00 for each adult $10.00 for each child $5.00 for each...
Prompt the user for their name, get and store the user input. Prompt the user for...
Prompt the user for their name, get and store the user input. Prompt the user for their age, get and store the user input. We will assume that the user will enter a positive integer and will do no error checking for valid input. Determine and store a movie ticket price based on the user's age. If their age is 12 or under, the ticket price is $5. If their age is between 13 and 64, inclusive, the ticket price...
Write a program that gathers input from the user and writes the information out to a...
Write a program that gathers input from the user and writes the information out to a file (output.txt).   Your main method should gather the input, calculate the average, and write the output. You should have a separate method that writes the output to a file. You can have other methods as well if you choose. However, you MUST have at least one other method in addition to the main method. Inputs: Student Number Name Class name Grades 1-5 (5 individual...
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
Create a C++ program that will prompt the user to input an positive integer number and...
Create a C++ program that will prompt the user to input an positive integer number and output the corresponding number to words. Check all possible invalid input data. (Please use only switch or if-else statements. Thank you.)
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream> and switch and if-else statements only. Thank you. Ex. Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four Enter a number: 100000 One Hundred Thousand Enter a number: -2 Number should be from 0-1000000 only
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT