While x size if itemordered productsx then output

This preview shows page 18 - 23 out of 500 pages.

while x < SIZE if itemOrdered = PRODUCTS[x] then output PRICES[x] x = SIZE found = 1 total = total + PRICES[x] else x = x + 1 endif endwhile if found = 0 then output ERROR_MSG endif output “Enter an item or ”, QUIT, “ to complete your order” input itemOrdered return finishUp() output “Your order total is: $”, total return Number Name 1 Personnel 8. Design the application logic for a company that wants a report containing a breakdown of pa Departm ent Departm ent
2 Marketing 3 4 5 Sales 6 7 Shipping Answer: A sample solution follows Flowchart: Pseudocode: start Declarations num deptNum num salary num hrsWorked num SIZE = 7 num grossTotals[SIZE] = 0 string DEPTS[SIZE] = “Personnel”, “Marketing”, “Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping” 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 grossTotals[deptNum - 1] = grossTotals [d(hrsWorked * sal else output “Invalid department number” endif output “Enter the department number, hourly salary, and number of Manufact uring Computer Services Accountin g Table 6-4 Department numbers and names
hours worked” input deptNum, salary, hrsWorked return finishUp() deptNum = 0 while deptNum < SIZE output deptNum + 1, DEPTS[deptNum], grossTotals [deptNum] deptNum = deptNum + 1 endwhile return 10 13 16 20 Flowchart: Pseudocode: start Declarations string empName num salary num hrsWorked num x num grossPay num withTax num netPay num totalGrossPay = 0 9. Design a program that computes pay for employees. Allow a user to continuously input emp Weekly Gross Pay ($) Withhold ing Percent (%) 0.00 – 300.00 300.01 550.00 550.01 800.00 800.01 up .000 Table 6-5 Withholding percentage based on gross pay Answer: A sample solution follows
num totalHrsWorked = 0 num totalWithTax = 0 num totalNetPay = 0 string QUIT = “zzzz” num SIZE = 4 num WITH_RATES[SIZE] = 0.10, 0.13, 0.16, 0.20 num WITH_RANGES[SIZE] = 0, 300.01, 550.01, 800.01 getReady() while empName <> 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_RANGES[x] x = x – 1 endwhile withTax = grossPay * WITH_RATES[x] totalWithTax = totalWithTax + withTax netPay = grossPay – withTax totalNetPay = totalNetPay + netPay output empName, grossPay, WITH_RATES[x] * 100, withTax, netPay output “Enter an employee name or ”, QUIT, “ to quit” input empName return finishUp() output totalHrsWorked, totalGrossPay, totalWithTax, totalNetPay return Code 1 Chicago 300 2 Boston 480 10. Countrywide Tours conducts sightseeing trips for groups from its home base in Iowa. Create Destinati on Price per Person ($)
3 Miami 1050 4 1300 Design the logic for an application that outputs each tour number, validated start date, destinatio 5-Jan 0 12-Jun 75

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture