1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anon25 [30]
3 years ago
14

Number Analysis Program: Write a program that reads data from the text file numbers.txt. Assume the file contains a series of nu

mbers, each written on a separate line. The program should read the numbers from the file and store them into the array numbers. Then program should display the lowest value, the highest value in the array. Also calculate and display the average of these values.
Computers and Technology
1 answer:
diamong [38]3 years ago
8 0

Answer:

See Explaination

Explanation:

#include <iostream>

#include <fstream>

#include <string>

#include <iomanip>

// namespace std

using namespace std;

// start of the main function

int main() {

// setting precision to 2 decimal point

cout << fixed << setprecision(2) << endl;

// variable declration

int i, count = 0;

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

double sum = 0;

double Avg;

// file object creation

ifstream infile;

string file;

// input the file name to read

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

"Analysis program "

<< endl;

getline(cin, file);

infile.open(file.c_str());

// check if file exist or not

// and loop untill you get correct file name

// if you do not want to loop again and again then

// simply return 0; from code

if (infile.fail()) {

cout << "Error opening the file." << endl;

return 0;

// cout << "Please enter the name of the file to read numbers for Number "

// "Analysis program "

// << endl;

// getline(cin, file);

// infile.open(file.c_str());

}

// 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 < count; i++) {

if (arr[i] < min) {

min = arr[i];

}

}

for (i = 0; i < count; i++) {

// find the highest element

if (arr[i] > max) {

max = arr[i];

}

}

for (i = 0; i < count; i++) {

// calculate sum

sum = sum + arr[i];

}

Avg = sum / count;

// display output

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

cout << "The lowest value is " << min << endl;

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

cout << endl;

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

return 0;

} // end of the main program

You might be interested in
100 POINTS!!!!!!!!
raketka [301]

Answer:

Option B

Securing Unattended Equipments

3 0
3 years ago
Read 2 more answers
Is ryan patrick cullen gay
pshichka [43]

who is that? ..........

6 0
3 years ago
Read 2 more answers
What is a graph,a chart then give similarities between graph and chart.​
Alik [6]

Answer:

A diagram showing the relation between variable quantities, typically of two variables, each measured along one of a pair of axes at right angles. A collection of points whose coordinates satisfy a given relation. A sheet of information in the form of a table, graph, or diagram. Normally graphs and charts in excel are very much similar to each other, but they are different, Graphs are mostly a numerical representation of data as it shows the relation of change in numbers that how one number is affecting or changing another, however, charts are the visual representation where categories may or may not be related to each other also how the information is displayed is different in both graphs and charts.

6 0
3 years ago
Read 2 more answers
Consider a three sequentially stepped process named as Process A, Process B and Process C. Input comes into Process A. Output fo
Novay_Z [31]

Answer: The process B is at the maximum steady state. A process is said to be at steady state if the variables that define the behavior of the system are unchanging

Explanation: From the Above

Process A takes 2 minutes per unit and hence can process (60/2) = 30 units per hour. Process B can process only (60/3) = 20 units per hour. Process C can handle (60/1) = 60 units per hour. the steady state output from this system is the smallest of the three, that is process B 20 units per hour

4 0
4 years ago
Compare the two types of formatting that IDE devices must go through. What is the primary difference between the two?
Andrei [34K]
A quick format<span> changes the file system while the </span>full format<span> also checks the </span>drive for bad sectors.  <span>The scan for bad sectors is the reason why the Full </span>format<span> takes twice as long as the </span>Quick format<span>. If you choose the </span>Quick format<span> option, the </span>format<span> removes address files from the partition, but does not scan the disk for bad sectors.</span>
7 0
3 years ago
Read 2 more answers
Other questions:
  • You are boating on a lake. the weather turns bad. what should all passengers do first?
    14·2 answers
  • numbers that the user inputs. You must use JoptionPane to input the three numbers. A first method must be called and used to dev
    13·1 answer
  • A compressed format featuring small file size and good quality that is commonly used for online videos and music videos is BIN.
    8·1 answer
  • Egovernment involves the use of strategies and technologies to transform government by improving the delivery of services and en
    7·1 answer
  • Children's Web sites may combine educational and entertaining information and activities with interactive advertising and direct
    5·2 answers
  • ____ is an approach to boundary spanning which results from using sophisticated software to search through large amounts of inte
    5·1 answer
  • Consider the following code segment. The code is intended to read nonnegative numbers and compute their product until a negative
    11·1 answer
  • In most programming languages, the compiler carries a preprocessing step to determine if certain statements will compile. For in
    7·1 answer
  • Someone plzzzz help me
    5·1 answer
  • ITING THE ANSWER
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!