B revise the profit determining program so that it

This preview shows page 3 - 6 out of 7 pages.

b. Revise the profit-determining program so that it runs continuously for any number of cars. The detail loop executes continuously while the sale price is not 0; in addition to calculating the profit, it prompts the user for and gets the next sale price. The end-of-job module executes after 0 is entered for the sale price. b. Hierarchy chart: Flowchart: start ---------housekeeping ------------------ detailLoop() | | | | | output PURCHASE_PROMPT | output | | SALE_PROMPT | | | | input salePrice input purchasePrice | | | | return profit = salePrice-purchasePrice
| Declarations | numsalePrice output profit numpurchasePrice | num profit | string SALE_PROMPT = “Enter sale price” output SALE_PROMPT string PURCHASE_PROMPT = “Enter the purchase price”. | | | | input salePrice housekeeping | | yes salePrice<>0? --detail loop() return | no end-of-job | stop Declarations num salePrice num salePricee num profit string WHOLESALE_PROMPT = “Enter the sale price.” string PURCHASE_PROMPT = “Enter the purchase price.” string END_LINE = “Thanks for using this program”. Housekeeping() salePrice <> 0? endOfJob() stop Pseudocode: start Declarations num salePrice
num salePrice num profit string SALE_PROMPT = “Enter the wholesale price: ” string wholesale_PROMPT = “Enter the wholesale price: ” string END_LINE = “Thanks for using this program” housekeeping() while wholesalePrice <> 0 detailLoop() endwhile endOfJob () stop housekeeping () output sale_PROMPT input wholesalePrice return detailLoop() output sale_PROMPT

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture