Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this question has been answered previously but does not work. So I am asking that it be answered again with the ability to run sample

this question has been answered previously but does not work. So I am asking that it be answered again with the ability to run sample files as the question requires. Thank you

Write a program that reads sales data from a file. The program outputs the totals sales, average sales, lowest and highest sales.

Outcomes:

1. Read data from a file into an array.

2. Process data in a partially filled array via functions.

3. Pass an array as a parameter to a function.

4. Use for and while loops when processing an array.

Specifications:

1. Use an array to store the sales data. Sales data should be stored as a double.

2. The company has at most 20 locations. (Max capacity of the array)

3. The input file contains a sales report that list the number of stores reporting data and the sales data.

4. Sample Input file format: (samplefile1 and samplefile2)

3

27648.92 234.83 23458.32

The '3' means that this file contains data for three locations. The numbers represent the sales for each location.

5. The main function should be modular so the main tasks must be handled by functions. Note: this is only an outline of the function requirements. You will need to decide on function names, parameter lists and return types on your own.

6. The tasks are:

a. Ask the user for the file name that contains the sales data. Fill the array with the sales data from a file.

b. Total the sales data.

c. Average the sales data.

d. Determine the highest sales in the report.

e. Determine the lowest sales from the report

7. The main function should output the data to the user.

8. Add code to the main function to allow the user to rerun the program.

9. Sample output:

Enter file name: sales.dat

The total sales are $755260.00

The average sales amount is $ 75526.00

The highest sales amount is $124569.00

The lowest sales amount is $ 35678.00

10. Extra Credit (15 points) Write two additional functions:

a. Write a function that sorts the arrays sales data in ascending order. You may not use selection sort. Bubble sort example.

b. Write a function that displays all the elements of the array in a nicely formatted output.

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

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

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions