Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Design and implement an application file that does the following: uses a 2 dimensional array to store the sales data(see sample data and output

Problem Design and implement an application file that does the following: uses a 2 dimensional array to store the sales data(see sample data and output below). Your program must be able to correctly process any data set that has the format outlined below, including different amounts of stores (cities) and months uses 1 dimensional arrays for the following: hold the names of the stores hold the total sales for each store (city) hold the monthly totals creates 4 methods that perform the following tasks. Each method must be called from main(). Try to open the input file, sales.txt (already created for you), then read data from the file. See note below for code that you can use to connect to the file. Handle the IOException in this method by asking the user to try entering the file name again. calculates the total sales for each city calculates the monthly totals prints out the results (see the sample output below) to both the screen and to an output file. If you want help getting the output to line up, use printf (or ask you instructor about printf). The results should be printed to both the screen and to an output file.

The number of stores (cities) and the number of months will be the first line of data to read. (number of stores first, then number of months). The cities names will come next, one per line. Finally the monthly sales for one store (city) will be next, one citys data per line.

Sample Input Data (contained in sales.txt): This is a sample data set only. Your program must be able to correctly process any data set that has this format. 7 6 Chilliwack Kamloops Kelowna Nanaimo Surrey Vancouver Victoria 400 500 500 600 500 600 600 800 800 800 900 900 700 700 700 900 900 1000 500 600 700 800 700 700 800 700 800 700 900 800 1000 1100 1200 1300 1400 1400 900 900 900 1000 1100 1100

Sample Output: Store Monthly Sales Store Location (thousands of $) Totals Jan Feb Mar Apr May Jun Chilliwack 400 500 500 600 500 600 3100 Kamloops 600 800 800 800 900 900 4800 Kelowna 700 700 700 900 900 1000 4900 Nanaimo 500 600 700 800 700 700 4000 Surrey 800 700 800 700 900 800 4700 Vancouver 1000 1100 1200 1300 1400 1400 7400 Victoria 900 900 900 1000 1100 1100 5900 Month Totals 4900 5300 5600 6100 6400 6500 34800

Assignment Submission: Submit print-outs of the application file, and the output file.

Notes: 1. use this in method #1 to connect to the file, then read from it: File file = new File(sales.txt); Scanner input = new Scanner(file); (use the normal Scanner methods to read the data, as if it was coming from the keyboard)

After you read the first 2 integers youll need to execute this statement to skip over the end-of-line symbol that hasnt been read by input.nextInt( ): input.nextLine( );

the method that contains this code must handle the IOException

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Advances In Databases 28th British National Conference On Databases Bncod 28 Manchester Uk July 2011 Revised Selected Papers Lncs 7051

Authors: Alvaro A.A. Fernandes ,Alasdair J.G. Gray ,Khalid Belhajjame

2011th Edition

3642245765, 978-3642245763

More Books

Students also viewed these Databases questions

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago