7 design the application logic for a company that

This preview shows page 22 - 28 out of 56 pages.

7. Design the application logic for a company that wants a report containing a breakdown of payroll by department. Input includes each employee’s department number, hourly salary, and number of hours worked. The output is a list of the seven departments in the company and the total gross payroll (rate times hours) for each department. The department names are shown in the accompanying table. 22
Programming Logic and Design, 6e Solutions 6- Department Number Department Name 1 Personnel 2 Marketing 3 Manufacturing 4 Computer Services 5 Sales 6 Accounting 7 Shipping Answer: A sample solution follows Flowchart: 23
Programming Logic and Design, 6e Solutions 6- Pseudocode: start Declarations num deptNum num salary num hrsWorked num SIZE = 7 num totalGross[SIZE] = 0 string DEPTS[SIZE] = “Personnel”, “Marketing”, “Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping” 24
Programming Logic and Design, 6e Solutions 6- getReady() while not eof detailLoop() endwhile finishUp() stop getReady() output “Enter the department number, hourly salary, and number of hours worked” input deptNum, salary, hrsWorked return detailLoop() if deptNum >= 1 AND deptNum <= SIZE then totalGross[deptNum-1] = totalGross[deptNum-1] + (hrsWorked * salary) else output “Invalid department number” endif output “Enter the department number, hourly salary, and number of hours worked” input deptNum, salary, hrsWorked return finishUp() deptNum = 0 while deptNum < SIZE output deptNum+1, DEPTS[deptNum], totalGross[deptNum] deptNum = deptNum + 1 endwhile return 8. Design a program that computes pay for employees. Allow a user to continuously input employees’ names until an appropriate sentinel value is entered. Also input each employee’s hourly wage and hours worked. Compute each employee’s gross pay (hours times rate), withholding tax percentage (based on the accompanying table), withholding tax amount, and net pay (gross pay minus withholding tax). Display all the results for each employee. After the last employee has been entered, display the sum of all the hours worked, the total gross payroll, the total withholding for all employees, and the total net payroll. Weekly Gross Pay Withholding Percent (%) 0.00 – 200.00 10 200.01 – 350.00 14 350.01 – 500.00 18 500.01 – up .000 22 Answer: A sample solution follows Flowchart: 25
Programming Logic and Design, 6e Solutions 6- Pseudocode: start Declarations string empName num salary 26
Programming Logic and Design, 6e Solutions 6- num hrsWorked num x num grossPay num withTax num netPay num totalGrossPay = 0 num totalHrsWorked = 0 num totalWithTax = 0 num totalNetPay = 0 string QUIT = “zzzz” num SIZE = 4 num WITH_RATE[SIZE] = 0.10, 0.14, 0.18, 0.22 num WITH_RANGE[SIZE] = 0, 200.01, 350.01, 500.01 getReady() while empName not equal to QUIT detailLoop() endwhile finishUp() stop getReady() output “Enter an employee name or ”, QUIT, “ to quit” input empName return detailLoop() output “Enter ”, empName, “’s hourly wage and hours worked” input salary, hoursWorked grossPay = hrsWorked * salary totalHrsWorked = totalHrsWorked + hrsWorked totalGrossPay = totalGrossPay + grossPay x = SIZE – 1 while grossPay < WITH_RANGE[x] x = x – 1 endwhile withTax = grossPay * WITH_RATE[x] totalWithTax = totalWithTax + withTax netPay = grossPay – withTax

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture