Write a program that inputs (from the user) the number of hours worked and hourl
ID: 3654748 • Letter: W
Question
Write a program that inputs (from the user) the number of hours worked and hourly pay rate for employees and outputs their total pay. The program should process an arbitrary number of employees; the user will terminate input by entering 0 for hours worked and pay rate. Use a class called Worker with Attributes: Hours, Rate, Total Methods: ComputerTotal(), and access methods (SetHours(), GetHours(), SetRate(), GetRate(), SetTotal(), and getTotal()) for each of the attributes. Draw a flowchart and write a pseudocode for this program.Explanation / Answer
Class Worker // Attributes Employee's Pay Declare Hours as Float Declare Rate as Float Declare Total as Float Subprogram SetHours(Hours) Set Hours = Subprogram ComputeTotal() Set Total = Rate * Hours End Subprogram Main Write” Please input the Employee’s Pay Rate. Input 0 to end” Input Rate End if Rate = 0 Write“ Input the Total Hours worked. Input 0 to end.” Input Hours End if Hours =0 Write “This Employees’ Total Pay is “ + Total 1. Don't ask and check for the user to enter zero for the second question. 2. For the main function, you're going to need a loop to allow the user to define how many employee he needs to enter. I recommend setting up and infinite loop with a break when the user enters zero. Like this: Do // First user question here // Store Data If UserInput = 0 Then Break End If // Second user question here // Store Data Loop // Calculate Total
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.