JAVA program
Create a class called Array
Outside of the class, import the Scanner library
Outside of main declare two static final variables and integerfor number of days in the week and a double for the revenue perpizza (which is $8.50).
Create a method called main
Inside main:
- Declare an integer array that can hold the number of pizzaspurchased each day for one week.
- Declare two additional variables one to hold the total sum ofpizzas sold in a week and one to hold the average pizzas sold perday
- Instantiate a Scanner object
- Using an appropriate loop, ask the user to enter in the numberof pizza for each day
- The program must test the entry value.
- If the number entered is negative, the program must display anerror message and allow for the reentry of the value for that day.The program will continue to ask for a valid response until a validresponse is entered.
- If the number is valid (greater than or equal to zero), theprogram will then prompt for the next value until the loopends.
- Extra Credit will be given if the validation test is done via amethod call.
- Send the array to a method that displays a title for the reportas well as the number of pizzas sold for each day.
- Send the array to a method that calculates the sum total ofpizzas sold for the week; the method returns the sum total back tomain().
- Send the array to a method that calculates the average numberof pizzas sold for the week; the method returns the average back tomain().
- Display the following:
- The total number of pizzas sold for the week
- The average number of pizzas sold per day
- The total revenue from the pizza sold for the week
- The average revenue per day
- Display a thank you/goodbye message.
- Comment your code.
Screen Shots:
Please enter the number of pizzas sold for
Day 1: 5
Day 2: 9
Day 3: -3
Invalid value. Please enter valid value
Day 3: 3
Day 4: 12
Day 5: 4
Day 6: 16
Day 7: 22
Pizza Calculator
Sales Report
Day 1: 5
Day 2: 9
Day 3: 3
Day 4: 12
Day 5: 4
Day 6: 16
Day 7: 22
Total Pizzas Sold for the Week: 71
Average Pizza Sold for the week: 10.1
Total Revenue for the week: $603.50
Average Revenue per day: $86.21
Thank you for using Pizza Counter. Goodbye!