Advertisement
SmellyBadger

Untitled

Oct 18th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. Program Description
  2.  
  3. This program allows a user to buy books from a bookstore, entering the price one by one. Flat rates for either hard ($5) or paper copies ($2) are provided and they will be added to the cost based on the user selection. For example if the book’s cost is $10 and the user selects a hard copy then the total will be $15 before applying the discount. A ten-percent discount can be added if the user desires to. After the customer checks out the number of books he wants, the program provides a sale summary for both individual customers and sales for the day.
  4.  
  5. Input
  6. For this version, the input data has the following format:
  7. A character representing the desire to check out a new customer
  8. A character representing the desire to quit the system
  9. A character indicating whether the book is a hard or paper copy
  10. A character indicating whether or not the customer receives a 10 percent discount
  11. A float representing the cost of a book
  12.  
  13.  
  14. Output
  15. The following values will be calculated in the program solution:
  16. Customer section -
  17. Current customer number
  18. Count of books per customer
  19. Total Sale with tax and discount per customer
  20. Daily section -
  21. Average customer sale
  22. Max customer sale
  23. Total customer sale, without tax, for all customers for the day
  24. Total daily sales with tax, for all customers for the day
  25. Total tax amount for the day
  26. Total discount amount for the day
  27.  
  28. Additional Requirements:
  29.  
  30. You must use nested loops.
  31. The outer loop must use a proper sentinel loop pattern: -1 if you don't.
  32. The inner loop must use a proper sentinel loop pattern: -1 if you don't.
  33. .
  34. You need to check for bad data. If the cost is equal to zero, OR if it is less than zero, user should be prompted to re-enter a valid value.
  35.  
  36. As always, you must follow the Programming ground rules. Review them - and this write-up - just before handing in your solution to make sure you don't lose points for simple mistakes. Recall you are allowed at most 30 submittals to the Grader. Test well!
  37. For the prompt, user should be allowed to enter Upper case and Lower case, so for example, your program should allow the user to type ‘q or ‘Q’ to quit, ‘h’ or ‘H’ for hard copy, ‘d’ or ‘D’ to receive a discount, in addition to ‘c’ or ‘C’ for checking out. See the sample run below for more examples.
  38. For each customer, program should output current customer number, count of books and total sale with tax and discount.
  39. When the user chose to quit, the program should output the average customer sale, max customer sale, total customer sale (without tax) for all the customers for the day, total tax amount for the day, and total discount amount for the day.
  40.  
  41. Hints and Notes:
  42. Review Program 1 on how to start a project for a program.
  43. To display double quote in your cout statement, use \”. For example to display Enter “a” you must use the following string: Enter \”a\”
  44. Typing in the data as below is rather tedious. To read from a file such as P2_sample.txt, do the following:
  45. Copy P2_sample.txt from the same place you got this program description and save it to the same folder that you have saved your project. Make sure that you have turned on View File Name Extensions in File Explorer (View and under Show/Hide, put a check in "File name extensions") so you can see the file extensions.
  46. From Visual Studio 2017, with your project open, choose Project -> Properties
  47. At the left, under Configuration Properties, click on Debugging.
  48. In the right pane, under Command Arguments, type in a less than symbol and followed by the file name P2_sample.txt, like: <P2_sample.txt
  49. Run your program and note that the input is coming from the file instead of you having to type it in.
  50. To save the output to a file instead of sending it to the command window, go back to the Command Arguments text box in the Configuration Properties as described above. In the Command Arguments text box, type a space after the P2_sample.txt, and type in a greater than symbol followed by a meaningful file name like: <P2_sample.txt >P2_sample_out.txt
  51. This will create a file named P2_sample_out.txt in the same directory as your Project file. Then after running your program, you can browse to that output file on your J: drive (or wherever you saved it). You can view it in Notepad or any text editor.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement