Question: Program 1 : Must Compile or Zero points - or - incorrect results loose 1 2 poin Input validation for number of cash registers and
Program : Must Compile or Zero points or incorrect results loose 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:
Enter number of customers:
Customer:
Item Price
Item Price
Item Price
Item Price
Cash Register Used:
Total Price Paid:
Average Price Paid:
Customer:
Item Price
Cash Register Used:
Total Price Paid:
Average Price Paid:
Customer:
Item Price
Item Price
Item Price
Cash Register Used:
Total Price Paid:
Average Price Paid:
Some Helping Hints :
import java.util.Random;
import java.util.Scanner;
To get number from
numberfItems randGen.nextInt;
To get price from to
itemPrice Math.roundrandGennextDouble;
To format to decimal places
System.out.printfTotal Price Paid:
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 scnrnextInt
Get the number of customers numberOfCustomers using scnrnextInt
For each customer:
Get the number of items numberOfItems in grocery list using randGen.nextInt
For each item in grocery list numberOfItems
Get its price using randGen.nextDouble
Print the item number and price
Add this price to total price paid so far
Get register to checkout using scnrnextIntnumberOfCashRegisters
Print the following:
Cash register used
Total price paid at register
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 decimal places.
All code can be in main you do not have to break this up into separate methodsfunctions but you may if you want.
There should be no more than:
cash registers
customers
items in a grocery list
as a price of an item in the grocery list
User input must be checked for number of cash registers and number of customers
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
