Question: Program 1 : Must Compile or Zero points - or - incorrect results loose 1 2 poin Input validation for number of cash registers and

Program 1: Must Compile or Zero points - or - incorrect results loose 12 poin
Input validation for number of cash registers and customers
Total price and average price calculations are correct
All outputs shown as in example below Example Output:
Enter number of cash registers: 3
Enter number of customers: 3
Customer: 1
Item 01 Price=17.73
Item 02 Price=8.17
Item 03 Price =17.29
Item 04 Price =22.12
Cash Register Used: 2
Total Price Paid: 65.31
Average Price Paid: 16.33
Customer: 2
Item 01 Price=2.95
Cash Register Used: 3
Total Price Paid: 2.95
Average Price Paid: 2.95
Customer: 3
Item 01 Price =42.77
Item 02 Price =49.64
Item 03 Price =14.28
Cash Register Used: 3
Total Price Paid: 106.69
Average Price Paid: 35.56
Some Helping Hints :
import java.util.Random;
import java.util.Scanner;
To get number from 1..5
number0fItems = randGen.nextInt(5)+1;
To get price from 0.0 to 50.0
itemPrice = Math.round(randGen.nextDouble()*50*100.0)/100.0;
To format to 2 decimal places
System.out.printf("Total Price Paid: %2.02f?
, totalPrice);
Write a program that simulates the activity at a grocery store.
Each customer has a grocery list, fills their shopping cart and chooses a cash register.
Print the customer number, item number and cost, cash register used, total price and average price per item paid.
Assume the following declarations:
Scanner scnr = new Scanner(
System.in);
Random randGen = new Random (
Get the number of cash registers (numberOfCashRegisters) using scnr.nextInt(4)
Get the number of customers (numberOfCustomers) using scnr.nextInt(5)
For each customer:
3.1. Get the number of items (numberOfItems) in grocery list using randGen.nextInt(5)
3.2. For each item in grocery list (0.. numberOfItems)
3.2.1. Get its price using randGen.nextDouble()
3.2.2.Print the item number and price
3.2.3.Add this price to total price paid so far
3.3. Get register to checkout using scnr.nextInt(numberOfCashRegisters)
3.4. Print the following:
3.4.1. Cash register used
3.4.2. Total price paid at register
3.4.3.Average price of items bought
For the above, every time you see Get (in bold) it means the value is printed on its own line with the exception of:
The price for each item in the grocery list, these are printed all on one line, separated by spaces
All floats are printed to 2 decimal places.
All code can be in main() you do not have to break this up into separate methods/functions, but you may if you want.
There should be no more than:
4 cash registers
5 customers
5 items in a grocery list
50 as a price of an item in the grocery list
User input must be checked for number of cash registers (4) and number of customers(5)
 Program 1: Must Compile or Zero points - or - incorrect

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!