SlideShare a Scribd company logo
1 of 8
Download to read offline
***please help! READ the grading criteria***
HW5: Weekly Timesheet CSS 161 Fundamentals of Computing By: Hansel Ong Summary In
HW3, you created a program that allows the user to enter time worked on a week-by-week basis
Such a system calculated any hours worked over 40 hours a week as overtime. However, this
means that an employee could work 12 or 20 hours once a week, 4 hours the rest of the week,
and not be paid overtime at all. Let's fix this problem in this homework. For simplification, let's
limit the number of weeks the user can enter to two weeks maximum. Note also that any hours
worked in a day beyond 8 hours should be regarded as overtime hours. 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 loops and/or
arrays 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) Arrays File I/O Assignment Description
Write a program that does the following Provide the following "main menu" to the user (Create
a method for each of the choices): o (1 point) Enter/Edit Timesheet o (1 point) Display
Timesheet o (1 point) Print Paystub (End Program) o (1 point) Keep presenting this menu to the
user until user asks to print a paystub For "Enter/Edit Timesheet" o (1 point) Ask the user
which week the user would like to edit (1 or 2) (1 point) Return to "main menu" if user chooses
anything other than 1 or 2 o (2 points) Display each day of the week (M, Tu, W and the number
of hours worked for each day (display 0 by default until user has entered a value) (2 point) Allow
the user to edit hours for specific days of the week (1 point) Return to "main menu" if user
enters an invalid day of the week or invalid hours of the day
Solution
// Paystub.java
import java.util.Scanner;
public class Paystub
{
static int insuranceDeduction = 25;
static int regularHours1 = 0;
static int overtimeHours1 = 0;
static int regularHours2 = 0;
static int overtimeHours2 = 0;
static int[] week1 = new int[7];
static int[] week2 = new int[7];
public static int mainMenu()
{
System.out.println("  --------------Main Menu----------------");
System.out.print("1. Enter/Edit Timesheet 2. Display Timesheet 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 inputHours()
{
Scanner keyboard = new Scanner (System.in);
System.out.print("Which week Would you like to enter/edit(1 or 2): ");
int week = keyboard.nextInt();
if(week == 1)
{
for (int i = 0; i < 7 ; i++ )
{
System.out.println("Day " + (i+1) + ": " + week1[i] + " hours worked");
}
System.out.print("Which day Would you like to edit(1-7): ");
int day = keyboard.nextInt();
System.out.print("How many hours did you work on day " + day + "? " );
week1[day] = keyboard.nextInt();
if(week1[day] > 8)
{
regularHours1 = regularHours1 + 8;
overtimeHours1 = overtimeHours1 + (week1[day]-8);
}
else
{
regularHours1 = regularHours1 + week1[day];
}
}
else if(week == 2)
{
for (int i = 0; i < 7 ; i++ )
{
System.out.println("Day " + (i+1) + ": " + week2[i] + " hours worked");
}
System.out.print("Which day Would you like to edit(1-7): ");
int day = keyboard.nextInt();
System.out.print("How many hours did you work on day " + day + "? " );
week2[day] = keyboard.nextInt();
if(week2[day] > 8)
{
regularHours2 = regularHours2 + 8;
overtimeHours2 = overtimeHours2 + (week2[day]-8);
}
else
{
regularHours2 = regularHours2 + week2[day];
}
}
}
public static void display()
{
System.out.println(" -------------Week 1----------------");
System.out.println("Regular Hours: " + (regularHours1) + " Overtime hours: " +
(overtimeHours1) + " ");
System.out.println(" -------------Week 2----------------");
System.out.println("Regular Hours: " + (regularHours2) + " Overtime hours: " +
(overtimeHours2));
}
public static void paystub()
{
display();
double rate = 15.00;
double overtimeIncome, grossIncome, regularIncome;
int overtimeHours = overtimeHours1 + overtimeHours2;
int regularHours = regularHours1 + regularHours2;
regularIncome = regularHours*rate;
overtimeIncome = overtimeHours*1.5*rate;
grossIncome = overtimeIncome + regularIncome;
System.out.println(" ---------Gross Income---------------");
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 = 50;
double taxes = (grossIncome- insuranceDeduction )*0.3;
double takeHome = grossIncome-taxes- insuranceDeduction;
System.out.println(" ---------Deductions---------------");
System.out.println("Medical and Dental Insurance: $" + insuranceDeduction);
System.out.println("Federal Taxes: $" + taxes);
System.out.println(" ---------takehome Income---------------");
System.out.println("Takehome Income: $"+ regularIncome + "+ $" + overtimeIncome +
"- $" + insuranceDeduction + "- $" + taxes + " = $" + takeHome);
}
public static void main(String[] args)
{
for (int i = 0; i < 7 ; i++ )
{
week1[i] = 0;
week2[i] = 0;
}
while(true)
{
int choice = mainMenu();
if(choice == 1)
{
inputHours();
}
else if(choice == 2)
{
display();
}
else if(choice == 3)
{
paystub();
break;
}
else
System.out.println("Invalid Input");
}
System.out.println(" ************************************");
System.out.println("Thanks for using out system!");
System.out.println("************************************");
}
}
/*
output:
--------------Main Menu----------------
1. Enter/Edit Timesheet
2. Display Timesheet
3. Print Paystub (End program)
Please choose from the above options: 1
Which week Would you like to enter/edit(1 or 2): 1
Day 1: 0 hours worked
Day 2: 0 hours worked
Day 3: 0 hours worked
Day 4: 0 hours worked
Day 5: 0 hours worked
Day 6: 0 hours worked
Day 7: 0 hours worked
Which day Would you like to edit(1-7): 2
How many hours did you work on day 2? 7
--------------Main Menu----------------
1. Enter/Edit Timesheet
2. Display Timesheet
3. Print Paystub (End program)
Please choose from the above options: 1
Which week Would you like to enter/edit(1 or 2): 1
Day 1: 0 hours worked
Day 2: 0 hours worked
Day 3: 7 hours worked
Day 4: 0 hours worked
Day 5: 0 hours worked
Day 6: 0 hours worked
Day 7: 0 hours worked
Which day Would you like to edit(1-7): 4
How many hours did you work on day 4? 12
--------------Main Menu----------------
1. Enter/Edit Timesheet
2. Display Timesheet
3. Print Paystub (End program)
Please choose from the above options: 1
Which week Would you like to enter/edit(1 or 2): 2
Day 1: 0 hours worked
Day 2: 0 hours worked
Day 3: 0 hours worked
Day 4: 0 hours worked
Day 5: 0 hours worked
Day 6: 0 hours worked
Day 7: 0 hours worked
Which day Would you like to edit(1-7): 3
How many hours did you work on day 3? 10
--------------Main Menu----------------
1. Enter/Edit Timesheet
2. Display Timesheet
3. Print Paystub (End program)
Please choose from the above options: 2
-------------Week 1----------------
Regular Hours: 15
Overtime hours: 4
-------------Week 2----------------
Regular Hours: 8
Overtime hours: 2
--------------Main Menu----------------
1. Enter/Edit Timesheet
2. Display Timesheet
3. Print Paystub (End program)
Please choose from the above options: 3
-------------Week 1----------------
Regular Hours: 15
Overtime hours: 4
-------------Week 2----------------
Regular Hours: 8
Overtime hours: 2
---------Gross Income---------------
Regular Pay: 23 hours * $15.0 = $345.0
Overtime Pay: 6 hours * $15.0* 1.5 = $135.0
Gross Income: $480.0
---------Deductions---------------
Medical and Dental Insurance: $50
Federal Taxes: $129.0
---------takehome Income---------------
Takehome Income: $345.0+ $135.0- $50- $129.0 = $301.0
************************************
Thanks for using out system!
************************************
*/

More Related Content

Similar to please help! READ th.pdf

C++ program help! Cant find whats wrong with my program.The sa.pdf
C++ program help! Cant find whats wrong with my program.The sa.pdfC++ program help! Cant find whats wrong with my program.The sa.pdf
C++ program help! Cant find whats wrong with my program.The sa.pdffasttrackscardecors
 
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxMSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxgilpinleeanna
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxclarebernice
 
Honeywell 6160 px-scheduling-prox-tags
Honeywell 6160 px-scheduling-prox-tagsHoneywell 6160 px-scheduling-prox-tags
Honeywell 6160 px-scheduling-prox-tagsAlarm Grid
 
Video Case 1.2 throu 5.21.21. Why is the link between.docx
Video Case 1.2 throu 5.21.21.   Why is the link between.docxVideo Case 1.2 throu 5.21.21.   Why is the link between.docx
Video Case 1.2 throu 5.21.21. Why is the link between.docxdickonsondorris
 
Burnsheet Tool Description
Burnsheet Tool DescriptionBurnsheet Tool Description
Burnsheet Tool DescriptionDEEPANSHU GUPTA
 
C++ Help, I cant find whats wrong in my program. The sample outp.pdf
C++ Help, I cant find whats wrong in my program. The sample outp.pdfC++ Help, I cant find whats wrong in my program. The sample outp.pdf
C++ Help, I cant find whats wrong in my program. The sample outp.pdfinfo998421
 
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docxGanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docxbudbarber38650
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEWshyamuopeight
 
Operating Systems: Processor Management
Operating Systems: Processor ManagementOperating Systems: Processor Management
Operating Systems: Processor ManagementDamian T. Gordon
 
A computerized payroll system for the barangay hall
A computerized payroll system for the barangay hallA computerized payroll system for the barangay hall
A computerized payroll system for the barangay hallAcel Carl David O, Dolindo
 
1314 i a3-homework
1314 i a3-homework1314 i a3-homework
1314 i a3-homeworksaraaina27
 
I am constantly getting errors and cannot figure this out. Please he.pdf
I am constantly getting errors and cannot figure this out. Please he.pdfI am constantly getting errors and cannot figure this out. Please he.pdf
I am constantly getting errors and cannot figure this out. Please he.pdfallystraders
 
Asc timetables id_p1
Asc timetables id_p1Asc timetables id_p1
Asc timetables id_p1easeko agus
 
Functional Reactive Programming (RxJava) on Android
Functional Reactive Programming (RxJava) on AndroidFunctional Reactive Programming (RxJava) on Android
Functional Reactive Programming (RxJava) on AndroidRichard Radics
 

Similar to please help! READ th.pdf (18)

Oracle Primavera P6 PRO R8 Tips & tricks
Oracle Primavera P6 PRO R8 Tips & tricksOracle Primavera P6 PRO R8 Tips & tricks
Oracle Primavera P6 PRO R8 Tips & tricks
 
C++ program help! Cant find whats wrong with my program.The sa.pdf
C++ program help! Cant find whats wrong with my program.The sa.pdfC++ program help! Cant find whats wrong with my program.The sa.pdf
C++ program help! Cant find whats wrong with my program.The sa.pdf
 
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxMSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
 
Honeywell 6160 px-scheduling-prox-tags
Honeywell 6160 px-scheduling-prox-tagsHoneywell 6160 px-scheduling-prox-tags
Honeywell 6160 px-scheduling-prox-tags
 
Video Case 1.2 throu 5.21.21. Why is the link between.docx
Video Case 1.2 throu 5.21.21.   Why is the link between.docxVideo Case 1.2 throu 5.21.21.   Why is the link between.docx
Video Case 1.2 throu 5.21.21. Why is the link between.docx
 
Burnsheet Tool Description
Burnsheet Tool DescriptionBurnsheet Tool Description
Burnsheet Tool Description
 
Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
 
C++ Help, I cant find whats wrong in my program. The sample outp.pdf
C++ Help, I cant find whats wrong in my program. The sample outp.pdfC++ Help, I cant find whats wrong in my program. The sample outp.pdf
C++ Help, I cant find whats wrong in my program. The sample outp.pdf
 
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docxGanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
Operating Systems: Processor Management
Operating Systems: Processor ManagementOperating Systems: Processor Management
Operating Systems: Processor Management
 
Tutorial
TutorialTutorial
Tutorial
 
A computerized payroll system for the barangay hall
A computerized payroll system for the barangay hallA computerized payroll system for the barangay hall
A computerized payroll system for the barangay hall
 
1314 i a3-homework
1314 i a3-homework1314 i a3-homework
1314 i a3-homework
 
I am constantly getting errors and cannot figure this out. Please he.pdf
I am constantly getting errors and cannot figure this out. Please he.pdfI am constantly getting errors and cannot figure this out. Please he.pdf
I am constantly getting errors and cannot figure this out. Please he.pdf
 
Asc timetables id_p1
Asc timetables id_p1Asc timetables id_p1
Asc timetables id_p1
 
Functional Reactive Programming (RxJava) on Android
Functional Reactive Programming (RxJava) on AndroidFunctional Reactive Programming (RxJava) on Android
Functional Reactive Programming (RxJava) on Android
 

More from irshadkumar3

Describe the three ways in which protists can move. Provide an examp.pdf
Describe the three ways in which protists can move. Provide an examp.pdfDescribe the three ways in which protists can move. Provide an examp.pdf
Describe the three ways in which protists can move. Provide an examp.pdfirshadkumar3
 
A woman with type O blood gave birth to a baby, also with type O bloo.pdf
A woman with type O blood gave birth to a baby, also with type O bloo.pdfA woman with type O blood gave birth to a baby, also with type O bloo.pdf
A woman with type O blood gave birth to a baby, also with type O bloo.pdfirshadkumar3
 
A 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdf
A 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdfA 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdf
A 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdfirshadkumar3
 
Use the Internet to research one of the four modes of transportation.pdf
Use the Internet to research one of the four modes of transportation.pdfUse the Internet to research one of the four modes of transportation.pdf
Use the Internet to research one of the four modes of transportation.pdfirshadkumar3
 
Which of these worms are segmentedA.annelidsB.planariansC.rou.pdf
Which of these worms are segmentedA.annelidsB.planariansC.rou.pdfWhich of these worms are segmentedA.annelidsB.planariansC.rou.pdf
Which of these worms are segmentedA.annelidsB.planariansC.rou.pdfirshadkumar3
 
What are the proteins involved in this functions In lecture we dis.pdf
What are the proteins involved in this functions In lecture we dis.pdfWhat are the proteins involved in this functions In lecture we dis.pdf
What are the proteins involved in this functions In lecture we dis.pdfirshadkumar3
 
what are the best way to query optimization in MYSQL.SolutionT.pdf
what are the best way to query optimization in MYSQL.SolutionT.pdfwhat are the best way to query optimization in MYSQL.SolutionT.pdf
what are the best way to query optimization in MYSQL.SolutionT.pdfirshadkumar3
 
Using Social Media to Tell the Story of TOMS TOMS offers more than a.pdf
Using Social Media to Tell the Story of TOMS TOMS offers more than a.pdfUsing Social Media to Tell the Story of TOMS TOMS offers more than a.pdf
Using Social Media to Tell the Story of TOMS TOMS offers more than a.pdfirshadkumar3
 
The _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdf
The _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdfThe _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdf
The _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdfirshadkumar3
 
The functions f_1, f_2, ..., f_m defined on the interval I are said t.pdf
The functions f_1, f_2, ..., f_m defined on the interval I are said t.pdfThe functions f_1, f_2, ..., f_m defined on the interval I are said t.pdf
The functions f_1, f_2, ..., f_m defined on the interval I are said t.pdfirshadkumar3
 
Silica gel is slightly acidic. Will this cause an acidic compound to.pdf
Silica gel is slightly acidic. Will this cause an acidic compound to.pdfSilica gel is slightly acidic. Will this cause an acidic compound to.pdf
Silica gel is slightly acidic. Will this cause an acidic compound to.pdfirshadkumar3
 
Rank the four substances from least to most polar, Ethanol, pentanol.pdf
Rank the four substances from least to most polar, Ethanol, pentanol.pdfRank the four substances from least to most polar, Ethanol, pentanol.pdf
Rank the four substances from least to most polar, Ethanol, pentanol.pdfirshadkumar3
 
Compare and contrast the main approaches for developing a WBS. Which.pdf
Compare and contrast the main approaches for developing a WBS. Which.pdfCompare and contrast the main approaches for developing a WBS. Which.pdf
Compare and contrast the main approaches for developing a WBS. Which.pdfirshadkumar3
 
PROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdf
PROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdfPROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdf
PROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdfirshadkumar3
 
In 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdf
In 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdfIn 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdf
In 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdfirshadkumar3
 
Identify and explain, in order of occurrence, the four primary phase.pdf
Identify and explain, in order of occurrence, the four primary phase.pdfIdentify and explain, in order of occurrence, the four primary phase.pdf
Identify and explain, in order of occurrence, the four primary phase.pdfirshadkumar3
 
IA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdf
IA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdfIA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdf
IA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdfirshadkumar3
 
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdfI am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdfirshadkumar3
 
How do you do the last page. How do you make the picture with the t.pdf
How do you do the last page. How do you make the picture with the t.pdfHow do you do the last page. How do you make the picture with the t.pdf
How do you do the last page. How do you make the picture with the t.pdfirshadkumar3
 
How do auditors gain an understanding of the internal controls in an.pdf
How do auditors gain an understanding of the internal controls in an.pdfHow do auditors gain an understanding of the internal controls in an.pdf
How do auditors gain an understanding of the internal controls in an.pdfirshadkumar3
 

More from irshadkumar3 (20)

Describe the three ways in which protists can move. Provide an examp.pdf
Describe the three ways in which protists can move. Provide an examp.pdfDescribe the three ways in which protists can move. Provide an examp.pdf
Describe the three ways in which protists can move. Provide an examp.pdf
 
A woman with type O blood gave birth to a baby, also with type O bloo.pdf
A woman with type O blood gave birth to a baby, also with type O bloo.pdfA woman with type O blood gave birth to a baby, also with type O bloo.pdf
A woman with type O blood gave birth to a baby, also with type O bloo.pdf
 
A 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdf
A 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdfA 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdf
A 15 (ww) solution of BaCl2 in water has a density of 1.12 gmL..pdf
 
Use the Internet to research one of the four modes of transportation.pdf
Use the Internet to research one of the four modes of transportation.pdfUse the Internet to research one of the four modes of transportation.pdf
Use the Internet to research one of the four modes of transportation.pdf
 
Which of these worms are segmentedA.annelidsB.planariansC.rou.pdf
Which of these worms are segmentedA.annelidsB.planariansC.rou.pdfWhich of these worms are segmentedA.annelidsB.planariansC.rou.pdf
Which of these worms are segmentedA.annelidsB.planariansC.rou.pdf
 
What are the proteins involved in this functions In lecture we dis.pdf
What are the proteins involved in this functions In lecture we dis.pdfWhat are the proteins involved in this functions In lecture we dis.pdf
What are the proteins involved in this functions In lecture we dis.pdf
 
what are the best way to query optimization in MYSQL.SolutionT.pdf
what are the best way to query optimization in MYSQL.SolutionT.pdfwhat are the best way to query optimization in MYSQL.SolutionT.pdf
what are the best way to query optimization in MYSQL.SolutionT.pdf
 
Using Social Media to Tell the Story of TOMS TOMS offers more than a.pdf
Using Social Media to Tell the Story of TOMS TOMS offers more than a.pdfUsing Social Media to Tell the Story of TOMS TOMS offers more than a.pdf
Using Social Media to Tell the Story of TOMS TOMS offers more than a.pdf
 
The _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdf
The _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdfThe _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdf
The _____ were Roman merchantsSolutionCorrect AnswerPlebeia.pdf
 
The functions f_1, f_2, ..., f_m defined on the interval I are said t.pdf
The functions f_1, f_2, ..., f_m defined on the interval I are said t.pdfThe functions f_1, f_2, ..., f_m defined on the interval I are said t.pdf
The functions f_1, f_2, ..., f_m defined on the interval I are said t.pdf
 
Silica gel is slightly acidic. Will this cause an acidic compound to.pdf
Silica gel is slightly acidic. Will this cause an acidic compound to.pdfSilica gel is slightly acidic. Will this cause an acidic compound to.pdf
Silica gel is slightly acidic. Will this cause an acidic compound to.pdf
 
Rank the four substances from least to most polar, Ethanol, pentanol.pdf
Rank the four substances from least to most polar, Ethanol, pentanol.pdfRank the four substances from least to most polar, Ethanol, pentanol.pdf
Rank the four substances from least to most polar, Ethanol, pentanol.pdf
 
Compare and contrast the main approaches for developing a WBS. Which.pdf
Compare and contrast the main approaches for developing a WBS. Which.pdfCompare and contrast the main approaches for developing a WBS. Which.pdf
Compare and contrast the main approaches for developing a WBS. Which.pdf
 
PROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdf
PROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdfPROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdf
PROBLEM 4 Run runTerribleLoop for one hour. You can stop the prog.pdf
 
In 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdf
In 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdfIn 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdf
In 1972 the small kingdom of Bhutan, in Asia, developed a measure of.pdf
 
Identify and explain, in order of occurrence, the four primary phase.pdf
Identify and explain, in order of occurrence, the four primary phase.pdfIdentify and explain, in order of occurrence, the four primary phase.pdf
Identify and explain, in order of occurrence, the four primary phase.pdf
 
IA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdf
IA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdfIA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdf
IA 31 The reweycir deseers.ostains 4phaws G1,2, s, and M panes .pdf
 
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdfI am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
 
How do you do the last page. How do you make the picture with the t.pdf
How do you do the last page. How do you make the picture with the t.pdfHow do you do the last page. How do you make the picture with the t.pdf
How do you do the last page. How do you make the picture with the t.pdf
 
How do auditors gain an understanding of the internal controls in an.pdf
How do auditors gain an understanding of the internal controls in an.pdfHow do auditors gain an understanding of the internal controls in an.pdf
How do auditors gain an understanding of the internal controls in an.pdf
 

Recently uploaded

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

please help! READ th.pdf

  • 1. ***please help! READ the grading criteria*** HW5: Weekly Timesheet CSS 161 Fundamentals of Computing By: Hansel Ong Summary In HW3, you created a program that allows the user to enter time worked on a week-by-week basis Such a system calculated any hours worked over 40 hours a week as overtime. However, this means that an employee could work 12 or 20 hours once a week, 4 hours the rest of the week, and not be paid overtime at all. Let's fix this problem in this homework. For simplification, let's limit the number of weeks the user can enter to two weeks maximum. Note also that any hours worked in a day beyond 8 hours should be regarded as overtime hours. 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 loops and/or arrays 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) Arrays File I/O Assignment Description Write a program that does the following Provide the following "main menu" to the user (Create a method for each of the choices): o (1 point) Enter/Edit Timesheet o (1 point) Display Timesheet o (1 point) Print Paystub (End Program) o (1 point) Keep presenting this menu to the user until user asks to print a paystub For "Enter/Edit Timesheet" o (1 point) Ask the user which week the user would like to edit (1 or 2) (1 point) Return to "main menu" if user chooses anything other than 1 or 2 o (2 points) Display each day of the week (M, Tu, W and the number of hours worked for each day (display 0 by default until user has entered a value) (2 point) Allow the user to edit hours for specific days of the week (1 point) Return to "main menu" if user enters an invalid day of the week or invalid hours of the day Solution // Paystub.java import java.util.Scanner; public class Paystub { static int insuranceDeduction = 25;
  • 2. static int regularHours1 = 0; static int overtimeHours1 = 0; static int regularHours2 = 0; static int overtimeHours2 = 0; static int[] week1 = new int[7]; static int[] week2 = new int[7]; public static int mainMenu() { System.out.println(" --------------Main Menu----------------"); System.out.print("1. Enter/Edit Timesheet 2. Display Timesheet 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 inputHours() { Scanner keyboard = new Scanner (System.in); System.out.print("Which week Would you like to enter/edit(1 or 2): "); int week = keyboard.nextInt(); if(week == 1) { for (int i = 0; i < 7 ; i++ ) { System.out.println("Day " + (i+1) + ": " + week1[i] + " hours worked"); } System.out.print("Which day Would you like to edit(1-7): "); int day = keyboard.nextInt(); System.out.print("How many hours did you work on day " + day + "? " ); week1[day] = keyboard.nextInt(); if(week1[day] > 8) { regularHours1 = regularHours1 + 8; overtimeHours1 = overtimeHours1 + (week1[day]-8); }
  • 3. else { regularHours1 = regularHours1 + week1[day]; } } else if(week == 2) { for (int i = 0; i < 7 ; i++ ) { System.out.println("Day " + (i+1) + ": " + week2[i] + " hours worked"); } System.out.print("Which day Would you like to edit(1-7): "); int day = keyboard.nextInt(); System.out.print("How many hours did you work on day " + day + "? " ); week2[day] = keyboard.nextInt(); if(week2[day] > 8) { regularHours2 = regularHours2 + 8; overtimeHours2 = overtimeHours2 + (week2[day]-8); } else { regularHours2 = regularHours2 + week2[day]; } } } public static void display() { System.out.println(" -------------Week 1----------------"); System.out.println("Regular Hours: " + (regularHours1) + " Overtime hours: " + (overtimeHours1) + " "); System.out.println(" -------------Week 2----------------"); System.out.println("Regular Hours: " + (regularHours2) + " Overtime hours: " + (overtimeHours2)); }
  • 4. public static void paystub() { display(); double rate = 15.00; double overtimeIncome, grossIncome, regularIncome; int overtimeHours = overtimeHours1 + overtimeHours2; int regularHours = regularHours1 + regularHours2; regularIncome = regularHours*rate; overtimeIncome = overtimeHours*1.5*rate; grossIncome = overtimeIncome + regularIncome; System.out.println(" ---------Gross Income---------------"); 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 = 50; double taxes = (grossIncome- insuranceDeduction )*0.3; double takeHome = grossIncome-taxes- insuranceDeduction; System.out.println(" ---------Deductions---------------"); System.out.println("Medical and Dental Insurance: $" + insuranceDeduction); System.out.println("Federal Taxes: $" + taxes); System.out.println(" ---------takehome Income---------------"); System.out.println("Takehome Income: $"+ regularIncome + "+ $" + overtimeIncome + "- $" + insuranceDeduction + "- $" + taxes + " = $" + takeHome); } public static void main(String[] args) { for (int i = 0; i < 7 ; i++ ) { week1[i] = 0; week2[i] = 0;
  • 5. } while(true) { int choice = mainMenu(); if(choice == 1) { inputHours(); } else if(choice == 2) { display(); } else if(choice == 3) { paystub(); break; } else System.out.println("Invalid Input"); } System.out.println(" ************************************"); System.out.println("Thanks for using out system!"); System.out.println("************************************"); } } /* output: --------------Main Menu---------------- 1. Enter/Edit Timesheet 2. Display Timesheet 3. Print Paystub (End program) Please choose from the above options: 1 Which week Would you like to enter/edit(1 or 2): 1
  • 6. Day 1: 0 hours worked Day 2: 0 hours worked Day 3: 0 hours worked Day 4: 0 hours worked Day 5: 0 hours worked Day 6: 0 hours worked Day 7: 0 hours worked Which day Would you like to edit(1-7): 2 How many hours did you work on day 2? 7 --------------Main Menu---------------- 1. Enter/Edit Timesheet 2. Display Timesheet 3. Print Paystub (End program) Please choose from the above options: 1 Which week Would you like to enter/edit(1 or 2): 1 Day 1: 0 hours worked Day 2: 0 hours worked Day 3: 7 hours worked Day 4: 0 hours worked Day 5: 0 hours worked Day 6: 0 hours worked Day 7: 0 hours worked Which day Would you like to edit(1-7): 4 How many hours did you work on day 4? 12 --------------Main Menu---------------- 1. Enter/Edit Timesheet 2. Display Timesheet 3. Print Paystub (End program) Please choose from the above options: 1 Which week Would you like to enter/edit(1 or 2): 2 Day 1: 0 hours worked Day 2: 0 hours worked Day 3: 0 hours worked Day 4: 0 hours worked
  • 7. Day 5: 0 hours worked Day 6: 0 hours worked Day 7: 0 hours worked Which day Would you like to edit(1-7): 3 How many hours did you work on day 3? 10 --------------Main Menu---------------- 1. Enter/Edit Timesheet 2. Display Timesheet 3. Print Paystub (End program) Please choose from the above options: 2 -------------Week 1---------------- Regular Hours: 15 Overtime hours: 4 -------------Week 2---------------- Regular Hours: 8 Overtime hours: 2 --------------Main Menu---------------- 1. Enter/Edit Timesheet 2. Display Timesheet 3. Print Paystub (End program) Please choose from the above options: 3 -------------Week 1---------------- Regular Hours: 15 Overtime hours: 4 -------------Week 2---------------- Regular Hours: 8 Overtime hours: 2 ---------Gross Income--------------- Regular Pay: 23 hours * $15.0 = $345.0 Overtime Pay: 6 hours * $15.0* 1.5 = $135.0 Gross Income: $480.0 ---------Deductions---------------
  • 8. Medical and Dental Insurance: $50 Federal Taxes: $129.0 ---------takehome Income--------------- Takehome Income: $345.0+ $135.0- $50- $129.0 = $301.0 ************************************ Thanks for using out system! ************************************ */