Solutions 6 x x 1 endwhile return b a list of each

This preview shows page 40 - 45 out of 57 pages.

b. A list of each month of the year as both a number and a word (for example, “01 January”), and the total sales for the month for all salespeople40
Programming Logic and Design, 7eSolutions 6-Pseudocode:startDeclarationsnum hours, minutesnum month, day, year41
Programming Logic and Design, 7eSolutions 6-num saleAmtnum idNumnum person, xnum SSIZE = 4num PSIZE = 7num MSIZE = 12num totalSales[MSIZE] = 0num totalComm[PSIZE] = 0num ID_NUM[PSIZE] = 103, 104, 201, 319, 367, 388, 435string NAME[PSIZE] = “Darwin”, “Kratz”, “Shulstad”, “Fortune”, “Wickert”, “Miller”, “Vick”num SALE_AMT[SSIZE] = 0, 51000, 126000, 201000num COMM_RATE[SSIZE] = 0.04, 0.05, 0.06, 0.07string MONTHS[MSIZE] = “January”, “February”, “March”“April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”getReady()while not eofdetailLoop()endwhilefinishUp()stopgetReady()output “Enter the salesperson ID number”input idNumreturndetailLoop()person = 0while person < PSIZE AND idNum not equal to ID_NUM[person]person = person + 1endwhileif person = PSIZE thenoutput “An invalid number has been entered, please try again”elseinput month, day, year, hours, minutes, saleAmtwhile month < 1 OR month > 12 OR day < 1 OR day > 31output “Invalid date, please reenter”input month, day, yearendwhiletotalSales[month-1] = totalSales[month-1] + saleAmtendifoutput “Enter the salesperson ID number”input idNumreturnfinishUp()x = 0while x < MSIZEoutput x+1, MONTHS[x], totalSales[x]x = x + 1endwhilereturn42
Programming Logic and Design, 7eSolutions 6-c. A list of total sales as well as total commissions earned by all salespeople for each of the following time frames, based on hour of the day: 00–05, 06–12, 13–18, and 19–23Answer: A sample solution followsFlowchart: The flowchart will be similar to those shown in parts a and b.Pseudocode:startDeclarationsnum hours, minutesnum month, day, yearnum saleAmtnum idNumnum time, xnum SSIZE = 4num PSIZE = 7num TSIZE = 4num totalSales[TSIZE] = 0num totalComm[TSIZE] = 0num ID_NUM[PSIZE] = 103, 104, 201, 319, 367, 388, 435string NAME[PSIZE] = “Darwin”, “Kratz”, “Shulstad”, “Fortune”, “Wickert”, “Miller”, “Vick”num SALE_AMT[SSIZE] = 0, 51000, 126000, 201000num COMM_RATE[SSIZE] = 0.04, 0.05, 0.06, 0.07num TIME_RANGE[TSIZE] = 0, 6, 13, 19string TIMES[TSIZE] = “00-05", “06-12”, “13-18”, “19-23”getReady()while not eofdetailLoop()endwhilefinishUp()stopgetReady()output “Enter the salesperson ID number”input idNumreturndetailLoop()person = 0while person < PSIZE AND idNum not equal to ID_NUM[person]person = person + 1endwhileif person = PSIZE thenoutput “An invalid number has been entered, please try again”elseinput month, day, year, hours, minutes, saleAmt43
Programming Logic and Design, 7e

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture