Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework # 2 - CSC 1 0 0 AB ( C + + ) Supermarket Program Due: Thursday, February 1 7 ( at midnight )

Homework #2- CSC100AB (C++) Supermarket Program Due: Thursday, February 17(at midnight) Points: 10 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 1: 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 2: 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 2 for reference . if the amount is negative, and if so, SET the amount to zero. See Figure 3 for reference Step 3 Calculate and display the total cost Tips 1. Don't worry about your output displaying values such as 3.525 or 10.6[instead of 3.53/10.60, respectively). It'd be too tedious for you to format/handle properly. 2. Create variables to represent different things such as 'maxQuantity', price', 'total', etc. 3. Escope sequences are very handy to use here to help you format your output 4. YOU DO NOT have to do any sort of error handling for when the user enters a non-integer value for "amount'. For example, the user will not enter input such as: "","two", 4.3, etc. Requirements: 1. Comments are required. Use them to describe "sections" or "complex" parts of your code 2. Your price can be anything so long as it is NOT a whole integer value For example, values such as 3.50 or 2.75 are okay, but numbers such as 3 or 2 are not 3. Max Quantity can be whatever positive, non-zero value you like. 4. 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 2 & 35. 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, ...6.... 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 =10, userAmount;
double price =5.75, 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 =0;
}
// calculating the total cost
total = userAmount * price;
cout <"
the="" price="" of="""="">< useramount=""><"="" items="" is:="" $"=""><>
return 0;

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

Explain the importance of nonverbal messages.

Answered: 1 week ago

Question

Describe the advantages of effective listening.

Answered: 1 week ago

Question

Prepare an employment application.

Answered: 1 week ago