Design the application logic for a company that wants

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

8.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 Table 6-3.22
Programming Logic and Design, 9eSolutions 6-Department NumberDepartment Name1Personnel2Marketing3Manufacturing4Computer Services5Sales6Accounting7ShippingTable 6-3Department numbers and namesAnswer: A sample solution followsFlowchart:23
Programming Logic and Design, 9eSolutions 6-Pseudocode:startDeclarationsnum deptNumnum salarynum hrsWorkednum SIZE = 7num grossTotals[SIZE] = 0string DEPTS[SIZE] = “Personnel”, “Marketing”,“Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping”24
Programming Logic and Design, 9e9.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 eachemployee’s hourly wage and hours worked. Compute each employee’s gross pay (hours times rate), withholding tax percentage (based on Table 6-4), 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.Table 6-4Withholding percentage based on gross pay
Programming Logic and Design, 9eSolutions 6-Pseudocode:startDeclarations26
Programming Logic and Design, 9eSolutions 6-string empNamenum salarynum hrsWorkednum xnum grossPaynum withTaxnum netPaynum totalGrossPay = 0num totalHrsWorked = 0num totalWithTax = 0num totalNetPay = 0string QUIT = “zzzz”num SIZE = 4num WITH_RATES[SIZE] = 0.10, 0.13, 0.16, 0.20num WITH_RANGES[SIZE] = 0, 300.01, 550.01, 800.01 getReady()while empName <> QUITdetailLoop()endwhile finishUp()stopgetReady()output “Enter an employee name or ”, QUIT, “ to quit”input empNamereturndetailLoop()output “Enter ”, empName, “’s hourly wage and hours worked”input salary, hoursWorkedgrossPay = hrsWorked * salarytotalHrsWorked = totalHrsWorked + hrsWorkedtotalGrossPay = totalGrossPay + grossPayx = SIZE – 1while grossPay < WITH_RANGES[x]

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture