JAVA program Create a class called Array Outside of the class, import the Scanner library Outside of main...

70.2K

Verified Solution

Question

Programming

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:

  1. Declare an integer array that can hold the number of pizzaspurchased each day for one week.
  2. Declare two additional variables one to hold the total sum ofpizzas sold in a week and one to hold the average pizzas sold perday
  3. Instantiate a Scanner object
  4. Using an appropriate loop, ask the user to enter in the numberof pizza for each day
    1. The program must test the entry value.
    2. 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.
    3. If the number is valid (greater than or equal to zero), theprogram will then prompt for the next value until the loopends.
    4. Extra Credit will be given if the validation test is done via amethod call.
  5. Send the array to a method that displays a title for the reportas well as the number of pizzas sold for each day.
  6. Send the array to a method that calculates the sum total ofpizzas sold for the week; the method returns the sum total back tomain().
  7. Send the array to a method that calculates the average numberof pizzas sold for the week; the method returns the average back tomain().
  8. Display the following:
    1. The total number of pizzas sold for the week
    2. The average number of pizzas sold per day
    3. The total revenue from the pizza sold for the week
    4. The average revenue per day
  9. Display a thank you/goodbye message.
  10. 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!

Answer & Explanation Solved by verified expert
3.7 Ratings (489 Votes)
Here is the code in javaArrayjavaimport javautilpublic class Array    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students