讲解:ENGG1110、Programming、C/C++、c++R|Java

ENGG1110 — Problem Solving by Programming2019–2020 Term 1Project Specification — A Vending Machine Simulator1. IntroductionVending machines are automated machines that provide different products to consumers after paymentis accepted. For simplicity, we will be focusing on vending machines that take coins (available in HongKong) and provide beverages. A functional vending machine should also allow service personnel tocollect revenue and refill inventory.In this project, your task is to use C language to write a vending machine simulator that mimics its realcounterpart.2. FunctionalitiesSimilar to a real vending machine, the simulator should provide the following functions.For normal consumers:(a) Display product names and prices(b) Indicate if a product is out-of-stock(c) Take inserted coins(d) Indicate if inserted coin is sufficient for a product(e) Dispense product(f) Return inserted coins and changeFor service personnel:(g) Allow withdrawal of all inserted coins(h) Allow a product to be refilled(i) Allow a different product to be displayed4. Detailed Program FlowWhen the program starts, it should print the following front of the vending machine. Then a MainMenu with available options should be shown.Whenever an invalid choice is entered for any menu, the program should report and keep looping. Forexample (input is underlined):*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [ ] [ ] [ ] [ ] |*---------------------------*| [$ 0] || || [===] |*---------------------------*What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Open service menu (code required)0. QuitYour choice:What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Open service menu (code required)0. QuitYour choice: 8Invalid choice!What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Open service menu (code required)0. QuitYour choice:(v1.1)(1) Read product informationIf option 1 is chosen, the product names and the corresponding price will be displayed. Then the MainMenu is displayed again.What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Service menu (code required)0. QuitYour choice: 1(1) The displayed products are:A. Juice ($10)B. Cola ($6)C. Tea ($5)D. Water ($8)E. Coffee ($7)What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Service menu (code required)0. QuitYour choice: (v1.1)(2) Insert coinIf option 2 is chosen, a sub-menu with available coin options should be shown. After a coin is inserted,the front of vending machine with correct value of deposited coins should be shown (maximum: $99),then the sub-menu is shown again.(Assume the machine has $0 deposited at the beginning.)(2) Which coin would you like to insert?1. $12. $23. $54. $100. Go backYour choice: 2You have inserted $2.*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [ ] [ ] [ ] [ ] |*---------------------------*| [$ 2] || || [===] |*---------------------------*(2) Which coin would you like to insert?1. $12. $23. $54. $100. Go backYour choice:(v1.1)If the deposited money is sufficient to purchase a product, indicate it by “turning on the light” using acapital “O”.(Continuing from previous step.)(2) Which coin would you like to insert?1. $12. $23. $54. $100. Go backYour choice: 3You have inserted $5.*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [O] [O] [ ] [O] |*---------------------------*| [$ 7] || || [===] |*---------------------------*(2) Which coin would you like to insert?1. $12. $23. $54. $100. Go backYour choice:(v1.1)Selecting option 0 (Go back) will show the vending machine, and then return to the Main Menu.(Continuing from previous step.)(2) Which coin would you like to insert?1. $12. $23. $54. $100. Go backYour choice: 0Going back!*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [O] [O] [ ] [O] |*---------------------------*| [$ 7] || || [===] |*---------------------------*What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Open service menu (code required)0. QuitYour choice:(v1.1)(3) Press product buttonIf option 3 is chosen, a sub-menu with available product options should be shown. If the depositedmoney is sufficient to purchase the product chosen, the product will be dispensed. The front of vendingmachine with correct product dispensed, button lights and deposited value should be shown, then thesub-menu is shown again.(Assume that the machine has $7 deposited, and product B, C and E are affordable and available. Andthere is only one product B left.)Note that product B has just been sold out. There is an “X” on its button now. Also note that theremaining deposited amount will not be returned automatically. The product dispensed is assumed tobe taken when available, so that future display will not show this dispensed product again.(3) Which product button would you like to press?1. A2. B3. C4. D5. E0. Go backYour choice: 2You have pressed button B.*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [X] [ ] [ ] [ ] |*---------------------------*| [$ 1] || || [=B=] |*---------------------------*(3) Which product button would you like press?1. A2. B3. C4. D5. E0. Go backYour choice:(v1.1)If a button for an out-of-stock product or an unaffordable product is pressed, nothing will happen.(Continuing from previous step.)Selecting option 0 (Go back) will show the vending machine, and then return to the Main Menu (sameas before; not shown).(3) Which product button would you like to press?1. A2. B3. C4. D5. E0. Go backYour choice: 1You have pressed button A.*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [X] [ ] [ ] [ ] |*---------------------------*| [$ 1] || || [===] |*---------------------------*(3) Which product button would you like press?1. A2. B3. C4. D5. E0. Go backYour choice:(v1.1)(4) Press return buttonIf option 4 is chosen, all the deposited money will be returned. The front of vending machine withcorrect information should be shown, then the Main Menu is shown again.(Continuing from previous step.)(4) Return button is pressed.$1 has been returned.*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [X] [ ] [ ] [ ] |*---------------------------*| [$ 0] || || [===] |*---------------------------*What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Open service menu (code required)0. QuitYour choice: (v1.1)(9) Service MenuIf option 9 is chosen, the user is required to enter an access code (default: 1110). Incorrect code willcause the simulator to return to the Main Menu after showing an error message.C代做ENGG1110、代写Programming、代写C/Correct access code will allow the Service Menu to be shown.(9) Opening service menu. Access code is required.Enter access code: 1234Incorrect code!*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [X] [ ] [ ] [ ] |*---------------------------*| [$ 0] || || [===] |*---------------------------*What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Open service menu (code required)0. QuitYour choice:(9) Opening service menu. Access code is required.Enter access code: 1110Correct code!(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice:(v1.1)(9-1) Inspect machine statusIf option 1 is chosen in the Service Menu, the information about the revenue (money comes fromsales), inserted coins (money inserted but not used) and the products will be displayed. Then theService Menu is shown again.Selecting option 0 (Go back) will show the vending machine, and then return to the Main Menu (sameas before; not shown).(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice: 1(9-1) Machine statusAmount of revenue: $6Amount of inserted coins: $0Product information:A. Juice ($10) (5 left)B. Cola ($6) (sold out)C. Tea ($5) (2 left)D. Water ($8) (1 left)E. Coffee ($7) (9 left)(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice:(v1.1)(9-2) Withdraw all moneyIf option 2 is chosen in the Service Menu, all money in the machine (including coins that are insertedbut not used) will be withdrawn. Then the Service Menu is shown again.Selecting option 0 (Go back) will show the vending machine, and then return to the Main Menu (sameas before; not shown).(Continuing from previous step.)(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice: 2(9-2) All money is being withdrawn.$6 is withdrawn.(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice: 2(9-2) All Money is being withdrawn.$0 is withdrawn.(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice:(v1.1)(9-3) Refill productIf option 3 is chosen in the Service Menu, a sub-menu will be shown for the user to select the productto refill to the full quantity (fixed at 10 items). Then the Service Menu will be shown again.Selecting option 0 (Go back) will show the vending machine, and then return to the Main Menu (sameas before; not shown).(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice: 3(9-3) Which product would you like to refill?1. A2. B3. C4. D5. E0. Go backYour choice: 2You have refilled product B to full.(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice: (v1.1)(9-4) Change productIf option 4 is chosen in the Service Menu, a sub-menu will be shown for the user to select the productto change.Selecting option 0 (Go back) will show the vending machine, and then return to the Main Menu (sameas before; not shown).(9-4-1) Changing productAfter the product has been selected, the user is prompted to enter a new product name (maximum 20characters with no space) and new product price ($1–$99 with one dollar increments). The quantitywill be filled to full. Then the Service Menu is shown again.(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice: 3(9-4) Which product would you like to change?1. A2. B3. C4. D5. E0. Go backYour choice: 5You are changing product E.(9-4-1) Changing productEnter new product name: MilkEnter new product price: 4The new product E has been filled to full.(9) What would you like to do?1. Inspect machine status2. Withdraw all money3. Refill product4. Change product0. Go backYour choice:(v1.1)5. QuitIf option 0 is chosen in the top menu, the program will terminate. No message is given.*---------------------------*| Vending Machine |*---------------------------*| A B C D E || $10 $ 6 $ 5 $ 8 $ 7 || [ ] [ ] [ ] [ ] [ ] |*---------------------------*| [$ 0] || || [===] |*---------------------------*What would you like to do?1. Read product information2. Insert coin3. Press product button4. Press return button9. Open service menu (code required)0. QuitYour choice: 0> (v1.1)6. Academic Honesty and Declaration StatementAttention is drawn to University policy and regulations on honesty in academic work, and to thedisciplinary guidelines and procedures applicable to breaches of such policy and regulations. Detailsmay be found at https://www.cuhk.edu.hk/policy/academichonesty/.Please put the following declaration statement as the comment in the beginning of your source codeand fill in your information./*** ENGG1110 Problem Solving by Programming** Course Project** I declare that the project here submitted is original* except for source material explicitly acknowledged,* and that the same or closely related material has not been* previously submitted for another course.* I also acknowledge that I am aware of University policy and* regulations on honesty in academic work, and of the disciplinary* guidelines and procedures applicable to breaches of such* policy and regulations, as contained in the website.** University Guideline on Academic Honesty:* https://www.cuhk.edu.hk/policy/academichonesty/** Student Name : * Student ID : * Class/Section : * Date : */7. Testing PlatformYour code will be tested on Repl.it platform. Modular testing will be provided to let you confirm thecorrectness of certain parts of your program.8. Code and Report SubmissionYour code will be submitted on both Repl.it and Blackboard. You are also required to submit a flowchart describing the flow of your program.9. ScheduleSubmission (code and flowchart) by 23:59, Sunday, December 8, 2019 on Blackboard(v1.1)10. Assumptions and Initial ConditionsYou can safely assume the following conditions during program execution.(1) All menu inputs from user are integers.(2) All product names have maximum 20 characters and no spaces in between.(3) All product prices are between $1 and $99.(4) Maximum amount of inserted coins is $99. Behavior is not defined if more than $99 areinserted.(5) Access code for service menu (option 9) will be entered as integer and will be treated asinteger. So, both entered codes 1110 and 001110 will grant access.(6) When changing product (action 9-4-1), newly entered product name and price will obey theabove assumptions (2) and (3).(7) No need to preserve machine status (i.e., revenue, inserted coins, product names and prices)between program executions. Every time the program starts, it should be reset to the initialconditions (as described below).Your vending machine should have the following initial conditions every time the program starts.• Amount of revenue: $0• Amount of inserted coins: $0• Product information:A. Juice ($10) (5 left)B. Cola ($6) (1 left)C. Tea ($5) (2 left)D. Water ($8) (1 left)E. Coffee ($7) (9 left)转自:http://www.6daixie.com/contents/13/4460.html

你可能感兴趣的:(讲解:ENGG1110、Programming、C/C++、c++R|Java)