Question: Please make program basic, were only on while and for loops A store sells three different items. Let us call these as Item A ,

Please make program basic, were only on while and for loops
A store sells three different items. Let us call these as Item A, Item B and Item C. Let the initial
stock/count of these items be Count ?A, Count ?B and Count ?C respectively. Customers keep buying
some of these items. Eventually, one or more of these items will run out of stock/count. Write a Java
program that initially loads the counts of these three items, allows customers to buy these items and
indicates when an item (or more than an item) goes out of stock.
Programming requirements
You must read the values of Count ?A, Count ?B and Count ?C from input. You must validate the
counts (each one must be positive).
You must print the three stocks/counts as soon as they are initialized.
Start a while loop. Inside the loop, read two inputs - an item code (1,2 or 3 corresponding to
Item A, Item B or Item C respectively), and the quantity of that item. You must validate the
item code and quantity (must be positive). This corresponds to a customer buying an item.
Reduce the stock/count of the corresponding item, ONLY IF the quantity the customer buys is
less than or equal to corresponding stock/count of that item. Otherwise, print a message saying
that there is not enough stock/count of that item.
Print the stock/count of each item after each transaction.
Terminate the while loop when all three counts become zero.
 Please make program basic, were only on while and for loops

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!