Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sales Figures Write a java program called Sales2D that creates a randomly generated twodimensional array of sales figures. Use a command line argument to determine

image text in transcribed
Sales Figures Write a java program called Sales2D that creates a randomly generated twodimensional array of sales figures. Use a command line argument to determine how many weeks' worth of sales data are desired. Don't forget to check that the user supplied a command line argument, and quit the program immediately if they don't - with a message to the user to remind them how to properly initiate your program. Create a 2D array of type int to hold 7 sales amounts per week. Each week's worth of data forms one row in the array. Thus the array has one row for each week and 7 columns. Each entry in the array is a monetary amount stored in pennies, so the number 123456 represents $1,234.56. Fill the array with randomly generated data, where each sales figure is between $1,000.00 and $5,000.00 inclusive. Declare constants ('final' variables) to replace the use of numbers like 7 in your code. Display your array as a 2D table, using Numberformat to format the values as currency. and right-aligning each column of data. You may include row and column headings if you wish, but this is not a requirement. Once your array is fully populated with numbers, answer the following questions: - For each week determine the lowest sales amount that week, the highest sales amount that week, and the difference between the two. Produce a listing that shows those three amounts for each week. - Which day of the week accounts for the lowest average sales per day? Include in this result the name of the day, for example "Monday' - What is the average sales per day for that day of the week? Clearly label your answers to each of those questions in your output. Treat column 0 as Monday and column 6 as Sunday. To associate the day names with the columns, create either (a) an enumerated type representing the days of the week, or (b) an array of Strings holding the day names (your choice). Use this to help label your answers to those questions with day names (rather than simply providing a column index in your output, for instance). If you choose to use an enumerated type, you can review the RottenApplesEnum class discussed in Module 11 for an example. Submit output for three sample runs: - 1 week's worth of data - 3 weeks' worth of data - 10 weeks' worth of data

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions