/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package sixthfall16; import java.util.Scanner; /** * * @author jcmtiernan */ public class SixthFall16 { /** * @param args the command line arguments */ public static void main(String[] args) { double hoursWorked; double fullWeekMax = 40.0; double fullWeekMin = 37.0; double moreHours = 0.0; Scanner input = new Scanner(System.in); int weeksInMonth; int weekCounter = 0; boolean validWeeks = true; double payPerHour = 12.50; double overtimeRate = 1.5; double totalPay = 0; int payType; // 0 = hourly, 1 = weekly salary, 2 = commission double payPerWeek = 600.0; double commissionRate = .15; // 15% commission double itemPrice; /* This program is going to figure out a person's pay for a month based on how they get paid. They can be paid hourly, by weekly salary, or by commission for items sold. */ // from previous class System.out.print("Please entered the number of weeks you worked this month: "); weeksInMonth = input.nextInt(); /* Error check and save results in validWeeks*/ if ((weeksInMonth < 0) || (weeksInMonth > 4)) { validWeeks = false; } if (validWeeks) { // --- Print a line of the table titles pay for the week for (weekCounter =1 ;weekCounter <= weeksInMonth; weekCounter++ ) { System.out.print("Please entered the hours you worked in week " +weekCounter+" this month: "); hoursWorked = input.nextDouble(); // We should error check the number of hours if (hoursWorked > fullWeekMax) { // true result Overtime totalPay += (fullWeekMin * payPerHour) + ((hoursWorked- fullWeekMin )* overtimeRate * payPerHour); // 40 hours payPerHour plus 1.5 * hours over 40 } else if (hoursWorked < fullWeekMin) { // true result Partial totalPay += hoursWorked * payPerHour;// hours * payPerHour } else { // else Regular totalPay += hoursWorked * payPerHour; // 40 hours payPerHour } // --- Print a line of the table showing pay for the week } System.out.println("Total pay for "+weeksInMonth+" weeks is "+totalPay); } else { System.out.println("You entered an invalid number of weeks"); } /* do { System.out.println("Reducing weekCounter "+weekCounter); weekCounter--; } while (weekCounter > 0); */ } }