// 10/11/2017 /** The Payroll class calculates the Net Pay for two * employees. This is version 4 of the Payroll class. * This version uses a while loop. * next time: read in a value * use sentinel * read from file * (and review for exam) */ import java.util.Scanner; public class Payroll4 { /** * pay is calculated by multiplying hours times rate, and * then subtracting 11% for taxes. */ public static void main(String[] args) { final double TAXES = .11; // employees pay 11% income tax double taxes=0.0, rate=0.0, pay=0.0; int hoursWorked=0; String name; Scanner readObject = new Scanner(System.in); int numEmployees=200; // hard coding the # of employees // while loop to process employees while (numEmployees>0) { // prompt the user to enter a name System.out.print("Enter a name of employee: "); name = readObject.nextLine(); // prompt the user to enter data for hours and rate System.out.print("Enter number of hours worked and rate of pay: "); hoursWorked = readObject.nextInt(); rate = readObject.nextDouble(); pay = rate * hoursWorked; taxes = TAXES*pay; pay-=taxes; System.out.println("Name Hours Rate Pay"); System.out.println("----------------------------"); System.out.printf("%s %4d $%4.2f $%,8.2f\n",name, hoursWorked, rate, pay); numEmployees--; readObject.nextLine(); // to skip newline in input buffer } } } /** Lab assignment: * Read in an integer from keyboard. * Print a msg saying that you are going to count by 2's. * Print all even numbers that are less than or equal to the number * that you read in. * For example: if you read in the value 10, your program will print: * This program will display all even values less than or equal 10. * 10 * 8 * 6 * 4 * 2 * Or you can display: 2 4 6 8 10 */