Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please make a flowchart and pseudocode . #include #include #include #include using namespace std; void getInfo(ifstream& , const int, int[]); int getTotal(const int, int[]); double

please make a flowchart and pseudocode .

#include

#include

#include

#include

using namespace std;

void getInfo(ifstream& , const int, int[]);

int getTotal(const int, int[]);

double getAverage(const int, int[]);

int getHighest(const int, int[]);

int getLowest(const int, int[]);

int main()

{

const int ARRAY_SIZE = 12;

int numbers[ARRAY_SIZE];

double total,

average,

lowestNumber,

highestNumber;

string filename;

ifstream inputFile;

int count = 0;

cout << "Please enter the name of the file to read numbers for Number Analysis program ";

cin >> filename;

inputFile.open(filename);

if (inputFile)

{

getInfo(inputFile,ARRAY_SIZE,numbers);

inputFile.close();

highestNumber = getHighest(ARRAY_SIZE, numbers);

cout << "The highest value is " << highestNumber << endl;

lowestNumber = getLowest(ARRAY_SIZE, numbers);

cout << "The lowest values is " << lowestNumber << endl;

total = getTotal( ARRAY_SIZE, numbers);

cout << "The sum of the numbers is " << total << endl << endl;

cout << fixed << setprecision(2);

average = getAverage(ARRAY_SIZE, numbers);

cout << "The average of the numbers is " << average << endl;

}

else

{

cout << "Error opening the file. ";

}

system("pause");

return 0;

}

void getInfo(ifstream &inputFile, const int ARRAY_SIZE,int numbers[] )

{

int count = 0;

while (count < ARRAY_SIZE)

{

inputFile >> numbers[count];

count++;

}

}

int getTotal(const int ARRAY_SIZE, int numbers[])

{

int total = 0;

for (int count = 0; count < ARRAY_SIZE; count++)

total += numbers[count];

return total;

}

double getAverage(const int ARRAY_SIZE, int numbers[])

{

double average = 0;

double total;

total = getTotal(ARRAY_SIZE, numbers);

average = total / ARRAY_SIZE;

return average;

}

int getLowest(const int ARRAY_SIZE, int numbers[])

{

int lowest;

lowest = numbers[0];

for (int count = 1; count < ARRAY_SIZE; count++)

{

if (numbers[count] < lowest)

lowest = numbers[count];

}

return lowest;

}

int getHighest(const int ARRAY_SIZE, int numbers[])

{

int highest;

highest = numbers[0];

for (int count = 1; count < ARRAY_SIZE; count++)

{

if (numbers[count] > highest)

highest = numbers[count];

}

return highest;

}

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

b. Will there be one assigned leader?

Answered: 1 week ago

Question

Do you currently have a team agreement?

Answered: 1 week ago