CISC1600: Computer Science I Lab 2
Purpose: In this lab assignment of CIS1600, we will continue to get familiar with the
programming environment on storm, and write a small program to practice and reinforce our
understanding of C/C++ variables, including how to read values for variables from standard
input, how to write variables to standard output, and how to perform basic arithmetic operations.
Points: 20 points total
Instruction: We will write a small program for Little Italy Pizzeria to calculate how much to
charge each customer based on their orders. Please name your program cashier.cpp.
The restaurant sells two types of pizza: 12 inch pizza ($12.39 each) and 14 in pizza ($15.98
each).
Your program works as follows:
- Prompt the user (i.e., the cashier) to enter his/her name
- Read the user's name (first name)
- Prompt the user (i.e., the cashier) to input the number of 12 inch pizzas being ordered
- Read the number of 12 inch pizzas into a variable
- Prompt the user (i.e., the cashier) to input the number of 14 inch pizzas being ordered
- Read the number of 14 inch pizzas into a variable
- Calculate the total amount due
- Prompt the user to enter the amount received from the customer
- Calculate and display the amount of changes due to the customer.
- Display a receipt on the terminal, listing the key information including the name of the store,
the name, quantity, and total price for each kind of pizza, the amount received, and the total changes, and finally the cashier's name.
As the following example shows, the receipt is delimited by horizontal lines.
An example run of your program is as follows, where the user inputs are underlined, and the program output are shown in regular format:
$ ./pizzarCashier
Welcome to Little Italy Pizzeria!
Please enter your first name:Larry
How many 12 inch pizzas ? 2
How many 14 inch pizzas ? 0
The total amount due is: $24.78
Enter the amount received: 40.00
Changes to give: $15.22
---------------------------------------
Receipt by Little Italy Pizzeria
-------------------------------
Name Quan Price
12-inch pizza 2 24.78
-------------------------------
Total 24.78
Amount received 40.00
Changes 15.22
Cashier: Larry
--------------------------------------
Hint
- Take an incremental approach, i.e., code a little, test a little.
First implement and test 1-2 steps, then add 3-6, ...
- If the program compiles but does not work as expected, consider
adding some cout statements to display the value of variables in order
to identify the errors.
- Recall: using the following command to compile your program:
g++ cashier.cpp
Or,
g++ cashier.cpp -o cashier.exe
Requirement:
- Please name your C++ programe (i.e., the source code) as Cashier.cpp.
- Please indent your code as the example code does.
- Use descriptive names (identifiers) for variables
- Use blank lines to separate the code into appropriate blocks
- Be sure to include comments to help others understand your program, and help yourself think!
How to submit
Email your source code to the instructor (xzhang@fordham.edu):