please help scroll down its more than one page Time Entry Su
******please help!***** scroll down its more than one page
Time Entry Summary You\'ve calculated gross income and created a simple paystub. However, all such tools are useless without the ability to enter time on a weekly basis for proper timekeeping purposes. HW2 assumed a two-week period between paystubs, but it only counted hours worked beyond 80 hours as overtime. However, this means that if an employee worked 60 hours one week and only 20 the next, that employee will not get any overtime hours at all. Let\'s fix this problem on this homework. Estimated Work Needed This assignment took me about 30-45 minutes to write (not including challenges, but including testing, commenting, and cleanup) in less than 200 lines of code. In other words, you should expect to spend between 135 to 450 minutes working on this assignment. If you\'ve spent more than 7.5 hours working on this assignment, then you are likely struggling with scope and/or loops and should re-read the lecture slides and attempt the exercises within seek help from your fellow classmates, myself, your lab instructor, QSC tutor, as well as online resources. Skills Expected All the skills from previous Assignment(s) Scope/Class Member Variables Loops Assignment Description Write a program that does the following: O Have the \"Insurance Deductions\" ($25) stored in a constant. O Ask the user for the following o First Name o Last Name Provide the following \"main menu\" to the user (Create a method for each of the choices) o (1 point) Enter Hours Worked O Display Summary o Print Paystub (End Program) Keep presenting the menu to the user until the user asks to print a paystub For Enter Hours Worked o Ask the user to enter hours worked on a weekly basis. Begin with Week 1 0 Be sure to check for valid values (What are valid values? What should you do for invalid values?) 0 Display a summary of regular and overtime hours recorded so far.Solution
// Paystub.java
import java.util.Scanner;
public class Paystub
{
static int insuranceDeduction = 25;
static int totalHours = 0;
static int regularHours = 0;
static int overtimeHours = 0;
static int week = 1;
public static int mainMenu()
{
System.out.println(\"\ \ --------------Main Menu----------------\");
System.out.print(\"1. Enter Hours Worked\ 2. Display Summary\ 3. Print Paystub (End program)\ Please choose from the above options: \");
Scanner keyboard = new Scanner (System.in);
int choice = keyboard.nextInt();
return choice;
}
public static void header(String firstName, String lastName)
{
System.out.println(\"\ ************************************\");
System.out.println(\"Paystub for \" + lastName + \", \" + firstName);
System.out.println(\"************************************\ \");
}
public static void inputHours()
{
String choice = \"y\";
while(true)
{
System.out.println(\"\ -------------Entering Hours----------------\");
Scanner keyboard = new Scanner (System.in);
System.out.print(\"How many hours did you work on week \" + (week) + \": \");
int hours = keyboard.nextInt();
while(true)
{
if(hours > 0)
break;
else
{
System.out.println(\"Invalid Input\");
System.out.print(\"How many hours did you work on week \" + (week) + \": \");
hours = keyboard.nextInt();
}
}
week++;
totalHours = totalHours + hours;
if(hours > 40)
{
System.out.println(\"Regular Hours: 40\ Overtime hours: \" + (hours-40));
regularHours = regularHours + 40;
overtimeHours = overtimeHours + hours-40;
}
else
{
System.out.println(\"Regular Hours: \" + (hours) + \"\ Overtime hours: 0.00\");
regularHours = regularHours + hours;
}
System.out.println(\"Would you like to enter more hours?(y/n) \");
choice = keyboard.next();
if(choice.equals(\"n\"))
break;
}
}
public static void display()
{
System.out.println(\"\ -------------Display Summary----------------\");
System.out.println(\"Regular Hours: \" + (regularHours) + \"\ Overtime hours: \" + (overtimeHours));
}
public static void paystub(String firstName, String lastName)
{
double rate = 15.00;
header(firstName,lastName);
System.out.println(\"Weeks worked: \" + week);
double overtimeIncome, grossIncome, regularIncome;
if (overtimeHours > 0)
{
regularIncome = 40*rate;
overtimeIncome = overtimeHours*1.5*rate;
}
else
{
overtimeIncome = 0.0;
regularIncome = regularHours*rate;
}
grossIncome = overtimeIncome + regularIncome;
System.out.println(\"Regular Pay: \" + regularHours + \" hours * $\" + rate + \" = $\" + regularIncome );
System.out.println(\"Overtime Pay: \" + overtimeHours + \" hours * $\" + rate + \"* 1.5 = $\" + overtimeIncome );
System.out.println(\"Gross Income: $\" +grossIncome );
insuranceDeduction = insuranceDeduction*(week-1);
double taxes = (grossIncome- insuranceDeduction )*0.3;
double takeHome = grossIncome-taxes- insuranceDeduction;
System.out.println(\"Medical and Dental Insurance: $\" + insuranceDeduction);
System.out.println(\"Federal Taxes: $\" + taxes);
System.out.println(\"Takehome Income: $\" + takeHome);
}
public static void main(String[] args)
{
Scanner keyboard = new Scanner (System.in);
System.out.print(\"What is your first name? \");
String firstName = keyboard.next();
System.out.print(\"What is your last name? \");
String lastName = keyboard.next();
while(true)
{
int choice = mainMenu();
if(choice == 1)
{
inputHours();
}
else if(choice == 2)
{
display();
}
else if(choice == 3)
{
paystub(firstName,lastName);
break;
}
else
System.out.println(\"Invalid Input\");
}
System.out.println(\"\ ************************************\");
System.out.println(\"Thanks for using out system!\");
System.out.println(\"************************************\");
}
}
/*
output:
What is your first name? Hansel
What is your last name? Ong
--------------Main Menu----------------
1. Enter Hours Worked
2. Display Summary
3. Print Paystub (End program)
Please choose from the above options: 1
-------------Entering Hours----------------
How many hours did you work on week 1: 43
Regular Hours: 40
Overtime hours: 3
Would you like to enter more hours?(y/n)
n
--------------Main Menu----------------
1. Enter Hours Worked
2. Display Summary
3. Print Paystub (End program)
Please choose from the above options: 2
-------------Display Summary----------------
Regular Hours: 40
Overtime hours: 3
--------------Main Menu----------------
1. Enter Hours Worked
2. Display Summary
3. Print Paystub (End program)
Please choose from the above options: 3
************************************
Paystub for Ong, Hansel
************************************
Weeks worked: 2
Regular Pay: 40 hours * $15.0 = $600.0
Overtime Pay: 3 hours * $15.0* 1.5 = $67.5
Gross Income: $667.5
Medical and Dental Insurance: $25
Federal Taxes: $192.75
Takehome Income: $449.75
************************************
Thanks for using out system!
************************************
*/



