Question: C++ Project 6: Number Analysis Program Concepts tested in this project: Reading data from a file into arrays Writing array data to files Passing arrays

C++ Project 6: Number Analysis Program

Concepts tested in this project:

Reading data from a file into arrays

Writing array data to files

Passing arrays to functions

Processing arrays using functions

Project Description

Write a program that asks the user for a file name. The program should read the contents of the file in to an array and then display the lowest number, the highest number, the total and average of the numbers in the array.

Project Specifications

Input for this project: Assume the file contains a series of 12 numbers, each written on a separate line. The user must enter the name of the input file.

Output: If the input file does not open, an error message should appear on the console. The program should display the following data:

The lowest number in the array

The highest number in the array

The total of the numbers in the array

The average of the numbers in the array

Processing Requirements

Use array in the main function for this project. Assume that the file contains numbers on separate lines and is constructed correctly.

Create functions for the following:

1. Read the numbers: Prompt for and get the input file name and try to open the file. If the file opens, read the numbers from the file, store them into the array. If the file does NOT open, print an error message on the console. If the file is not found, do NOT process the numbers.

2. Calculate and return the lowest number in the array. The numbers array should be a parameter.

3. Find and return the highest number in the array. The number array should be a parameter.

4. Find and return the total of all numbers in the number array. The number array should be a parameter.

5. Find and return the average of all numbers in the number array. The number array should be a parameter. The average should always show two decimal places.

C++ Project 6: Number Analysis Program Concepts tested in this project: Reading

data from a file into arrays Writing array data to files Passing

arrays to functions Processing arrays using functions Project Description Write a program

I need help my code doesnt run. Also i need help with the flowchart and pseudocode.

#include

#include

#include

#include

/amespace std

using namespace std;

//start of the main function

int main()

{

//setting precision to 2 decimal point

cout

//variable declration

int i, count = 0;

int min, max, value, arr[100];

double Avg, sum;

//file object creation

ifstream infile;

string file;

//input the file name to read

cout

getline(cin, file);

infile.open(file.c_str());

//check if file exist or not

if (!infile)

{

cout

}

//start reading the data from the file

while (infile >> value)

{

arr[count] = value;

count++;

}

//initialize min max to arr[0]

min = max = arr[0];

//find the lowest element

for (i = 0; i

{

if (arr[i]

{

min = arr[i];

}

}

for (i = 0; i

{

//find the highest element

if (arr[i]>max)

{

max = arr[i];

}

}

for (i = 0; i

{

//calculate sum

sum1 = sum + arr[i];

}

Avg = sum1 / count;

//display output

cout

cout

cout

cout

cout

cout

return 0;

}//end of the main program

CWINDOWS system321 cmd.exe Please enter the name of the file to read numbers for Number Analysis program numbers.txt The highest value is 89 The lowest value is 8 The sum of the numbers is 520 The average of the ntibers is 49.33 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!