Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

G Georgia Piedmont TxR Project Specification × Chegg Study l Guide × y D CIST231

ID: 3686781 • Letter: G

Question

G Georgia Piedmont TxR Project Specification × Chegg Study l Guide × y D CIST2311P.pdf C fi è file:///C:/Users/User/Pictures/CIST2311P.pdf . reate a program that will calculate emplovee's weekly pay as follows Inputs: 1) Name 2) Hourly Rate of Pay (S/hour) 3) Marital Status (Married, Single) 4) # of Dependents 5) Healthcare (Yes or No) 6) Hours worked ossible Screen: Name: Hourly Rate: Marital Status # Dependents: Married Health Insurance? Hours Worked Weekly Pay Gross Pay: Health Insurance: Federal Tax: Net Pay: Calculate Clear Outputs: 1) Gross pay (Hours over 40 are paid at time and 2) Health Insurance Amount 3) Federal Tax, calculated as follows: A. From gross taxable pay subtract $70 for each dependent B. From value in A subtract appropriate value in Standard Deduction Column from table C. D. E. F. below to give taxable gross. Tax at rate of 10% Tax at rate of 15% Tax at rate of 25% Tax at rate of 35% remaining amount (if any) in 35% Column from table below appropriate amount in 10% Column from table below appropriate amount in 15% Column from table below appropriate amount in 25% Column from table below Tax Rates 15% Deductions Marital Status Single Married 10% | $100 |$400 |-8800 25% Medical S60 $100 Standard $75 $150 | $101-$250 | $20 l-$500 | $25|-$400 | $50|-$800 4:18 AM 4/7/2016

Explanation / Answer

program to create package paycalculator; import java.util.Scanner; [ public class PayCalculator { public static void main(String[] args) { Scanner input; String employeeName; // Placeholder for employee name double hoursWorked; // the number of hours worked in a week double hourlyRate; // Employee's hourly rate double totalPay; // total hours worked plus the hourly rate double overtimePay = 0; // overtime pay double taxesWitheld; // Show Program Welcome Message System.out.println( "Employee Weekly Payroll Program "); // Tells program to show Welcome Message // while(true) // will loop until STOP is entered no particular letter case expected { input = new Scanner (System.in); // Show an Empty Line System.out.println( ); // On screen prompt for Employee Name System.out.print( "Enter the employee's name: " ); employeeName = input.nextLine(); // read the employee's name from memory do { // Prompt for Employee's Hourly Rate System.out.print( "Enter hourly rate: " ); // prompt message hourlyRate = input.nextDouble(); // reads employee's hourly rate if (hourlyRate < 0) { System.out.println( "ERROR: The hourly rate must be a positive number." ); // show error message } } while ( hourlyRate < 0 ); // end do while statement do { System.out.print( "Enter total hours worked this week: " ); // prompts the employee for hours worked for the week hoursWorked = input.nextDouble(); // reads number of hours entered and stores into memory if (hoursWorked < 0) { System.out.println( "ERROR: The number of hours worked must be a positive number." ); // shows error message } } while ( hoursWorked < 0 ); // end do while statement // Calculate Employee's Pay totalPay = hourlyRate * hoursWorked; // Calculate OVERTIME HOURS if (hoursWorked > 40) { overtimePay = (hoursWorked - 40) * (hourlyRate * 1.5); } else { totalPay = hoursWorked * hourlyRate; overtimePay = 0; } overtimePay = totalPay + overtimePay; taxesWitheld = overtimePay * (0.15); // Output program results to the display System.out.println( " WEEKLY PAYROLL RESULTS"); // Show Exit Message System.out.println( " Employee Name: " + employeeName); System.out.println( "Gross Pay: " + totalPay ); System.out.println( "Overtime Hours: " + overtimePay); //OVERTIME PAY // Show an Empty Line System.out.println( ); } // end while statement } // end method main } //end class Payroll public class Salary { public static void main(String[] args) { String payRate1 = JOptionPane.showInputDialog(null, "Please enter your pay rate: ", "PAY RATE", JOptionPane.QUESTION_MESSAGE); double payRate = Double.parseDouble(payRate1); String regHours = JOptionPane.showInputDialog(null, "Please enter regular hours worked: ", "REGULAR HOURS", JOptionPane.QUESTION_MESSAGE); int regHoursWorked = Integer.parseInt(regHours); String overtimeHours = JOptionPane.showInputDialog(null, "Please enter overtime hours worked: ", "OVERTIME HOURS", JOptionPane.QUESTION_MESSAGE); int overtimeHoursWorked = Integer.parseInt(overtimeHours); double grossPay = calculateRegularPay(payRate, regHoursWorked) + calculateOvertimePay(payRate, overtimeHoursWorked); System.out.println("Total Hours Worked: " + (regHoursWorked + overtimeHoursWorked)); System.out.println("Regular Pay: " + calculateRegularPay(payRate, regHoursWorked)); System.out.println("Overtime Pay: " + calculateOvertimePay(payRate, overtimeHoursWorked)); System.out.println("Gross Pay: " + grossPay); } public static double calculateRegularPay(double payRate, int regHoursWorked) { return payRate * regHoursWorked; } public static double calculateOvertimePay(double payRate, int overtimeHoursWorked) { return (payRate * 1.5) * overtimeHoursWorked; } }