Question: PROGRAMMING PROJECT: BUY ITEMS Objectives: Use basic C + + constructs: if , switch, and repetition ( looping ) Perform simple data type manipulations Solve

PROGRAMMING PROJECT: BUY ITEMS
Objectives:
Use basic C++ constructs: if, switch, and repetition (looping)
Perform simple data type manipulations
Solve problem, design solution and implement using C++
Description:
Write a menu-driven program named BuyItems.cpp that provides the following options:
1. Buy items by asking for the items description, price per item and the quantity
2. Show receipts by listing all the purchases
3. Show summary by listing only the number of purchases and the total purchase cost
Requirements:
1. The program must produce the provided expected sample output.
2. The user must enter the correct access code which is one of the followings (12345 or
54321) in order to start the program.
3. The program should NOT have any global variables
4. The program should have at least 3 functions and some documentation including your
name and programs description
Required error handling:
The program MUST perform the following checks:
1. Case-insensitive when to ask the user to confirm exiting the program (e.g. accepting both
Y and y)
2. Check for bad access code and allow up to 3 trials.
3. Check for negative or invalid price and/or quantity
4. Check for invalid menu answer
Sample program run 1
D:\>BuyItems
Welcome to my shopping program.
Please enter the access code: 12345
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: -1
Invalid selection. Please try it again.
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 5
Invalid selection. Please try it again.
Shopping Menu:
1. buy
2. show receipt
3. show summary
4. exit the program
Enter your option: Hello
Invalid selection. Please try it again.
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 1
Please enter the description: Book
Please enter the quantity: 10
Please enter the price for each item: 5
ITEM(Book) QUANTITY(10) PRICE($5.00) COST($50.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 1
Please enter the description: CD
Please enter the quantity: 2
Please enter the price for each item: 20
ITEM(CD) QUANTITY(2) PRICE($20.00) COST($40.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 1
Please enter the description: Movie
Please enter the quantity: 4
Please enter the price for each item: 8
ITEM(Movie) QUANTITY(4) PRICE($8.00) COST($32.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 2
List of all purchases:
ITEM(Book) QUANTITY(10) PRICE($5.00) COST($50.00)
ITEM(CD) QUANTITY(2) PRICE($20.00) COST($40.00)
ITEM(Movie) QUANTITY(4) PRICE($8.00) COST($32.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 3
PURCHASES(3) TOTAL_COST($122.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 4
Are you sure that you want to exit the program (y/n)? y
Thank you for using our program.
Thank you for using my program.
D:\>
Sample program run 2 invalid price and quantity input
D:\>BuyItems
Welcome to my shopping program.
Please enter the access code: 54321
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 1
Please enter the description: Book
Please enter the quantity: -1
Invalid quantity. Quantity cannot be negative or string. Please try it again.
Please enter the quantity: -10
Invalid quantity. Quantity cannot be negative or string. Please try it again.
Please enter the quantity: Hello
Invalid quantity. Quantity cannot be negative or string. Please try it again.
Please enter the quantity: 10
Please enter the price for each item: -1
Invalid price. Price cannot be negative or string. Please try it again.
Please enter the price for each item: -10
Invalid price. Price cannot be negative or string. Please try it again.
Please enter the price for each item: Hello
Invalid price. Price cannot be negative or string. Please try it again.
Please enter the price for each item: 5
ITEM(Book) QUANTITY(10) PRICE($5.00) COST($50.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 2
List of all purchases:
ITEM(Book) QUANTITY(10) PRICE($5.00) COST($50.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 3
PURCHASES(1) TOTAL_COST($50.00)
Shopping Menu:
1. buy
2. show receipts
3. show summary
4. exit the program
Enter your option: 4
Are you sure that you want to exit the program (y/n)? y
Thank you for using our program.
Thank you for using my program.
D:>
Sample program run 3 invalid access code
D:\>BuyItems
Welcome to my shopping program.
Please enter the access code: 123
Invalid access code. Please try it again.
P

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!