Logic7e_Solutions_ch04 - Programming Logic and Design 7e...

This preview shows page 1 - 6 out of 71 pages.

Programming Logic and Design, 7eSolutions 4-1Programming Logic and Design, 7th EditionChapter 4Exercises1.Assume that the following variables contain the values shown:numberBig = 300numberMedium = 100numberSmall = 5wordBig = “Elephant”wordMedium = “Horse”wordSmall = “Bug”For each of the following Boolean expressions, decide whether the statement is true,false, or illegal.Answer:a.numberBig = numberSmall?
b.numberBig > numberSmall?
c.numberMedium < numberSmall?
d.numberBig = wordBig?
e.numberBig = “Big”?
f.wordMedium = “Medium”?
g.wordBig = “Elephant”?
h.numberMedium <= numberBig / 3?
i.numberBig >= 200?
j.numberBig >= numberMedium + numberSmall?
k.numberBig > numberMedium AND numberBig < numberSmall?
l.numberBig = 100 OR numberBig > numberSmall?
m.numberBig < 10 OR numberSmall > 10?
?
2.Mortimer Life Insurance Company wants several lists of salesperson data. Design a flowchart or pseudocode for the following:a. A program that accepts a salesperson’s ID number and number of polices sold in the last month, and displays the data only if the salesperson is a high performer—a person who sells more than 25 policies in the month.
Programming Logic and Design, 7eSolutions 4-2Flowchart:Pseudocode:startDeclarationsnum idNumbernum policiesSoldnum POLICY_MIN = 25housekeeping()detail()finish()stophousekeeping()output “Salesperson program”input idNumber, policiesSoldreturndetail()if policiesSold > POLICY_MIN thenoutput idNumber, policiesSoldendifreturnfinish()output “End of program”return
Programming Logic and Design, 7eSolutions 4-3b. A program that accepts salesperson data continuously until a sentinel value is entered and displays a list of high performers.
Programming Logic and Design, 7eSolutions 4-4num policiesSoldnum POLICY_MIN = 25num QUIT = -1string ID_PROMPT = “Enter an ID number or -1 to quit >> ”housekeeping()while idNumber <> QUITdetailLoop()endwhilefinish()stophousekeeping()output ID_PROMPTinput idNumberreturndetailLoop()output “Enter policies sold >> ”input policiesSoldif policiesSold > POLICY_MIN thenoutput idNumber, policiesSoldendifoutput ID_PROMPTinput idNumberreturnfinish()output “End of program”return3.ShoppingBay is an online auction service that requires several reports. Design a flowchart or pseudocode for the following:a. A program that accepts auction data as follows: ID number, item description, lengthof auction in days, and minimum required bid. Display an auction’s data if the minimum required bid is over $100.00.
Programming Logic and Design, 7eSolutions 4-5Pseudocode:startDeclarationsnum idNumbernum numDaysnum minReqBidstring itemDescnum MIN_BID = 100housekeeping()detail()finish()stophousekeeping()output “Online Auction program”

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture