Wyo C++ Ch. 9 Programming Assignment

Ch9Proj1.cpp

A fruit stand owner wants you to write a program that will allow him to calculate the total cost of a customer's purchase. The customer will buy a certain number of apples, a certain number of pounds of grapes, and a certain number of candy bars. The apples are 50 cents each. Grapes must be purchased by the pound and cost 1.25 per pound. Candy bars are 85 cents but are taxed at the 6% PA state sales tax rate. Present the user with the following menu:

1 Apples
2 Grapes
3 Candy Bars
4 Checkout

The user will then be prompted to enter the quantity for the item he wishes to purchase. The program must use a loop to present the customer with the same menu allowing him to make one order of each 3 products if he desires. For example, the customer could order 3 apples and 4 pounds of grapes. Or, the customer could order 5 apples, 1 pound of grapes, and 3 candy bars. The customer is allowed to choose menu option #4 to checkout at any time, even if he has made no purchase. However, the customer should not be allowed to order the same product twice (within the same program execution). If he does choose the same menu choice a second time, display a message indicating that he cannot make two orders for the same product and display the menu again. Also, do not allow the customer to make any order that would cause the total amount of purchases (with tax included) to go over $100. If he attempts to place an order for an item that would cause the running total to exceed $100, display a message that explains that he can only spend $100 or less and present him with the menu again. He may place another valid order for the item that he attempted to purchase. If the user has purchased all three items, the program should automatically display the total rounded price as if the user selected the Checkout menu choice. Your program must display an output message along with the total amount of money due rounded to the hundredth's place. Trailing zeros do not have to be displayed (i.e. $2.8 is okay rather than $2.80). If the rounded total purchase (including tax) exceeds $100, even though the unrounded total purchase amount is less than or equal to $100, display a message that the whole order is rejected and end the program.

You must also use the following functions (besides the main function) to demonstrate modular, structured programming.

double computeSalesTax(double price, double taxRate)

// precondition: price is the amount of a taxable item, taxRate
//   is the tax percentage (6 for PA)
// postcondition: return the amount of tax, not the price of the item
//    with the tax added to it

void menu()
// precondition: none
// postcondition: the 4 menu choices is displayed,
//    do not include input statements (i.e. cin) in the menu

double round(double amount, int place)
// precondition: amount is a floating-point value to be rounded,
//    place is an integer that stands for the
//   place to which the function should round amount.
//   If place is 0, the function must round amount to the
//   nearest whole number. If place is 1, the function must
//   round amount to the tenths place. If places is 2, the
//   function must round amount to the hundredths place.

Your program must produce the exact same outputs as the sample cases in this test plan. You may use this Excel file which is stored in the mrmtemp folder on the network. for your test plan. However, you must create a test plan first and then pseudocode this assignment before you write the actual C++ code. Your program must follow the Coding Standards. Save the source code file as "Ch9Proj1.cpp" in the appropriate network folder.

Preconditions:

You must hand in the following on separate pages stapled in this specified order:

  1. The hardcopy source code for this assignment. Staple multiple pages together, if applicable.
  2. The typed pseudocode that you used to write out your C++ code. Please type this neatly following the specified template.
  3. The typed test plan (following the Excel template) that you developed before writing out the code. The test plan must include several reasonable inputs as well as boundary and any other special values. You should include as many test cases as necessary so that the test plan is thorough.