Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your program should have the following features: 1. Products (and their prices) that can be added to a user's cart will be stored in a
Your program should have the following features: 1. Products (and their prices) that can be added to a user's cart will be stored in a file called "product-database.txt". We will provide an example version of this file you can use. a. Each line is guaranteed to have a product name and its price separated by a space. b. NOTE: Your program should work with any file of any number of lines. 2. A menu will be displayed on loop to the user (meaning after a user completes a selection, the menu will be displayed again). Menu options should be: a. Add item: i. A list of available items will be displayed to the user. ii. A user will be asked for the name of the product they want to add to their cart. iii. If the product database contains the requested item, add 1 item to the cart and increase the cart total by the price of the item. Print the new number of items in the cart and the new total price of their cart. iv. If the item is not found in the product database, print an error message to the user and go back to the menu. V. NOTE: Your program does not have to keep track of which items the user adds to their cart, only the number of items added and the running total price of the cart. b. View cart i. The current number of items as well as the total price of the cart will be displayed to the user. c. Clear cart i. Set the number of items in the cart to 0 and set the price of the cart to $0.00. ii. Print the new cart details to the user. d. Check out i. The current number of items as well as the total price of the cart will be displayed to the user. ii. The user will have the option of paying in full, in 6 month payments, or in 12 month payments 1. If the user decides to pay in full, the entire total will be due at checkout. 2. If the user decides to pay in 6 month installments, 1% interest will be added to the total. 1/6th of that total will be due at checkout. 3. If the user decided to pay in 12 month installments, 2% interest will be added to the total. 1/12th of that total will be due at checkout. iii. For simplicity, the user will be asked to pay with a gift card. The user will enter the total amount they have on their gift card. 1. If the gift card amount is not enough to cover today's total, display an error message to the user. The cart will remain unchanged. 2. Otherwise, print the remaining gift card balance to the user and empty the cart. e. Exit i. A goodbye message will be displayed to the user and the program will quit Terminal output example, adding to cart Welcome to Mejiazon Red text = user input Green text = values from variables Blue text = info from file Black = terminal output Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit 1 Here are available products (from file): iPad 329.00 Xbox_SeriesX 399.00 PS5 499.00 MacBook Pro 1299.99 MacBook Air 999.99 Alexa_Speaker 79.99 Air_Fryer 129.00 Surface ProX 1299.99 Nintendo Switch 299.00 FIFA21 39.99 Type the name of the product you want Air Fryer You're adding more?!?! Current total: $129.0 Number of items: 1 Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit Terminal Output, view cart (3 items have been added to cart) Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 2 You're spending A LOT! jk current total: $957.0 Items : 3 Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit Terminal Output, clear cart Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 3 Total is now: $0.0 Items: 0 Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit Terminal Output, check out and pay in full (3 items have been added to cart) Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 4 You now have 3 options to check out: 1. 6 months of payments with 1% interest 2. 12 months of payments with 2% interest 3. Pay in full 3 Today you owe: $957.0 Enter gift card amount 1000 Thank you for shopping with Mejiazon! You're now broke! Remaining gift card balance: $43.0 Byeee! Terminal Output, check out and pay in 12 months (3 items have been added to cart) Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 4 You now have 3 options to check out: 1. 6 months of payments with 1% interest 12 months of payments with 2% interest 3. Pay in full 2. 2 $19.14 You will pay: $79.75 every month for 12m. Interest was: Today you owe: $79.75 Enter gift card amount 50 Your gift card doesn't have enough money! You now have 3 options to check out: 1. 6 months of payments with 1% interest 2. 12 months of payments with 2% interest 3. Pay in full Terminal Output, exit program Welcome to Mejiazon Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit 5 Cart abandoned. Goodbye! Your program should have the following features: 1. Products (and their prices) that can be added to a user's cart will be stored in a file called "product-database.txt". We will provide an example version of this file you can use. a. Each line is guaranteed to have a product name and its price separated by a space. b. NOTE: Your program should work with any file of any number of lines. 2. A menu will be displayed on loop to the user (meaning after a user completes a selection, the menu will be displayed again). Menu options should be: a. Add item: i. A list of available items will be displayed to the user. ii. A user will be asked for the name of the product they want to add to their cart. iii. If the product database contains the requested item, add 1 item to the cart and increase the cart total by the price of the item. Print the new number of items in the cart and the new total price of their cart. iv. If the item is not found in the product database, print an error message to the user and go back to the menu. V. NOTE: Your program does not have to keep track of which items the user adds to their cart, only the number of items added and the running total price of the cart. b. View cart i. The current number of items as well as the total price of the cart will be displayed to the user. c. Clear cart i. Set the number of items in the cart to 0 and set the price of the cart to $0.00. ii. Print the new cart details to the user. d. Check out i. The current number of items as well as the total price of the cart will be displayed to the user. ii. The user will have the option of paying in full, in 6 month payments, or in 12 month payments 1. If the user decides to pay in full, the entire total will be due at checkout. 2. If the user decides to pay in 6 month installments, 1% interest will be added to the total. 1/6th of that total will be due at checkout. 3. If the user decided to pay in 12 month installments, 2% interest will be added to the total. 1/12th of that total will be due at checkout. iii. For simplicity, the user will be asked to pay with a gift card. The user will enter the total amount they have on their gift card. 1. If the gift card amount is not enough to cover today's total, display an error message to the user. The cart will remain unchanged. 2. Otherwise, print the remaining gift card balance to the user and empty the cart. e. Exit i. A goodbye message will be displayed to the user and the program will quit Terminal output example, adding to cart Welcome to Mejiazon Red text = user input Green text = values from variables Blue text = info from file Black = terminal output Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit 1 Here are available products (from file): iPad 329.00 Xbox_SeriesX 399.00 PS5 499.00 MacBook Pro 1299.99 MacBook Air 999.99 Alexa_Speaker 79.99 Air_Fryer 129.00 Surface ProX 1299.99 Nintendo Switch 299.00 FIFA21 39.99 Type the name of the product you want Air Fryer You're adding more?!?! Current total: $129.0 Number of items: 1 Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit Terminal Output, view cart (3 items have been added to cart) Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 2 You're spending A LOT! jk current total: $957.0 Items : 3 Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit Terminal Output, clear cart Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 3 Total is now: $0.0 Items: 0 Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit Terminal Output, check out and pay in full (3 items have been added to cart) Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 4 You now have 3 options to check out: 1. 6 months of payments with 1% interest 2. 12 months of payments with 2% interest 3. Pay in full 3 Today you owe: $957.0 Enter gift card amount 1000 Thank you for shopping with Mejiazon! You're now broke! Remaining gift card balance: $43.0 Byeee! Terminal Output, check out and pay in 12 months (3 items have been added to cart) Choose one of the options below (1-5): 1. Add item 2. View cart 3. Clear cart 4. Check out 5. Exit 4 You now have 3 options to check out: 1. 6 months of payments with 1% interest 12 months of payments with 2% interest 3. Pay in full 2. 2 $19.14 You will pay: $79.75 every month for 12m. Interest was: Today you owe: $79.75 Enter gift card amount 50 Your gift card doesn't have enough money! You now have 3 options to check out: 1. 6 months of payments with 1% interest 2. 12 months of payments with 2% interest 3. Pay in full Terminal Output, exit program Welcome to Mejiazon Choose one of the options below (1-5): 1. Add item 2. View cart 3. clear cart 4. Check out 5. Exit 5 Cart abandoned. Goodbye
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started