Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment # 1 - Hogwarts Express Trolley Menu Due: Thursday 1 / 2 5 / 2 0 2 4 , 1 1 : 5 9

Assignment #1- Hogwarts Express Trolley Menu
Due: Thursday 1/25/2024,11:59:00pm
Objectives
To practice with writing a small C++ main() program, along with compiling and running it
To practice with basic C++ input/output features, along with some simple decimal formatting
To practice with basic arithmetic operators in C++
Task
Create a program (Filename: menu.cpp) that will simulate ordering different goodies from the Trolley as if you are on your way to Hogwarts. You will ask the user how many of certain candy items they'd like, calculate, and print the total for the customer, including wizard tax. (Yes, there's even taxes in the wizarding world).
Declare 4 CONSTANT double variables representing the prices of each item on the menu. The prices should be:
Bertie Botts Every Flavour Beans: $4.00
Chocolate Frog: $1.50
Exploding BonBons: $2.50
Cauldron Cake: $6.25
Use these variables anytime you need to do calculations that involve the prices of these items, or anytime you DISPLAY the prices of these items.
Declare a CONST double variable to represent the Wizard Tax rate of 6.5%
Welcome the user as seen in the sample runs, and print the Trolley menu. In the menu printout, make sure to use the CONST double variables you declared that represent the prices of each item to display on the menu. This way, in case the prices of the item changes, your menu will reflect the accurate prices.
As you can see in the sample execution below, you should ask the customer how many of each item that they would like, in order. These values/answers provided by the user will be of type int, and it's assumed that the user will only enter ints here. Prompt the user for these values exactly as I've done below. Store the amounts of each item the customer wants in variables you create to store these quantities.
After collecting the user's order quantities, your program should produce the output demonstrated in the sample execution, calculating and then printing the total before tax, tax, and total after tax. Also note that all prices must be printed to two decimal places
You may assume that all user input will be correct types. You do not need to handle any situation in which the user enters data of a wrong type (for instance, a letter (Character), instead of an integer)
Your goal is to make your output look as close to mine as possible (obviously the user entered values can change with every run of the program)
General Requirements
No global variables (variables outside of main())
Declare all variables at the top of your functions (including main()), instead of scattered throughout your code
All input and output must be done with streams, using the library iostream
You may only use the iostream and iomanip libraries (you do not need any others for these tasks)
NO C style printing is permitted. (Aka, don't use printf). Use cout if you need to print to the screen.
When you write source code, it should be readable and well-documented (comments).
Make sure to read your Style Guidelines .pdf (on our canvas home page) for our Programs. This is a graded factor of your homework.
Include the exact header given in our starter code on our canvas home page at the top of your source code file. Edit it appropriately with your information.
Write your program so that the output looks EXACTLY like the sample execution shown below (this means same wording, spacing, special characters you see in the sample below, and formatting of numbers). Use these sample runs to ensure you're doing your math correctly, but also make sure to test with other user entered values as well. Aka, you should not hard code any of these values in your program, the program you write should figure out the solution based on any user entered values.
Note: The underlining in the sample execution below is used to illustrate what the user is typing in -- obviously the underlining will not appear on the console.
Sample run 1: (user input underlined)
Anything off of the trolley, dears?
TROLLEY MENU
----------------------
Bertie Bott's Every Flavour Beans: $4.00
Chocolate Frog: $1.50
Exploding Bonbons: $2.50
Cauldron Cakes: $6.25
----------------------
How many Bertie Bott's Every Flavour Beans? -->2
How many Chocolate Frogs? -->0
How many Exploding Bonbons? -->0
How many Cauldron Cakes? -->1
Total (Before Wizard Tax): $14.25
Tax (6.50%): $0.93
Total (After Wizard Tax): $15.18
Enjoy your candies!
Sample run 2: (user input underlined)
Anything off of the trolley, dears?
TROLLEY MENU
----------------------
Bertie Bott's Every Flavour Beans: $4.00
Chocolate Frog: $1.50
Exploding Bonbons: $2.50
Cauldron Cakes: $6.25
----------------------
How many Bertie Bott's Every Flavour Beans? -->0
How many Chocolate Frogs? -->0
How many Exploding Bonbons? -->0
How many Cauldron Cakes? -->0
Total (Before Wizard Tax): $0.00
Tax (6.50%): $0.00
Total (After Wizard Tax): $0.00
Enjoy yo

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions