Question: Homework # 2 - CSC 1 0 0 AB ( C + + ) Supermarket Program Due: Thursday, February 1 7 ( at midnight )
Homework # CSCAB C Supermarket Program Due: Thursday, February at midnight Points: Write an interactive program where a "customer" is able to purchase an "imaginary" item. You need to be mindful on how your display looks and be able to handle user input accordingly. Here are the steps your program should follow: Step : Display to the user some details about your item. You need to convey the following info: The name of your item any name is fine Your item's price A maximum quantity Step : Prompt the user to enter in the amount they want. Once entered, be sure to check If the amount exceeds your max quantity, and if so set the amount to be your max quantity See Figure for reference if the amount is negative, and if so SET the amount to zero. See Figure for reference Step Calculate and display the total cost Tips Don't worry about your output displaying values such as or instead of respectively It'd be too tedious for you to formathandle properly. Create variables to represent different things such as 'maxQuantity', price', 'total', etc. Escope sequences are very handy to use here to help you format your output YOU DO NOT have to do any sort of error handling for when the user enters a noninteger value for "amount'. For example, the user will not enter input such as: "two", etc. Requirements: Comments are required. Use them to describe "sections" or "complex" parts of your code Your price can be anything so long as it is NOT a whole integer value For example, values such as or are okay, but numbers such as or are not Max Quantity can be whatever positive, nonzero value you like. if your program does change the user's entered value, be sure to let them know in your output. As seen in highlighted areas of Figures & Make sure your output is legible to the user. You can try to mimic my sample's approach or go about it your own unique way so long as all other requirements are still met HOWEVER, DO NOT copy my sample results values. come up with your own style and have fun with designing this program.
This is what I have and it is not working
driver function
#include
int main
int maxQuantity userAmount;
double price total;
display the item name, price and max quantity to the user
std::cout "item name:
std::cout "item price: $ price
std::cout "maximum quantity: maxquantity
prompting the user to enter the quantity they want
cout "enter the amount of items you want to buy:
cin userAmount;
updating the userAmount if the userAmount exceeds the maxQuantity
if userAmount maxQuantity
cout "the entered amount exceeds the maximum quantity
cout "setting the quantity to the maximum quantity available
userAmount maxQuantity;
updating the userAmount if the userAmount is negative
else if userAmount
cout "the entered amount is
cout "setting the quantity to
userAmount ;
calculating the total cost
total userAmount price;
cout
the price of useramount items is: $
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
