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
When creating a query using the query design command, first you must ____?
Doss [256]

You must first locate the queries group on the create tab. This tab contains the commands used to create queries. MS Access will switch itself to the query design view. A show table dialog box will appear and you will be able to select a table you would want to run a query on.






5 0
3 years ago
I need help in Jumbotron: Paragraph. The question is:
Aleksandr-060686 [28]
<span>.jumbotron p
{
color: #fff;
font-size: 20px;
}</span>
6 0
3 years ago
The ________ is a keyboard form based on the principle of voices imitating each other.
Brut [27]

A fugue is a keyboard form founded on the principles of voices imitating each other.

What is a fugue?

In theme, a fugue is a contrapuntal compositional process in two or more voices, built on a topic (a musical theme) that is presented at the beginning in imitation (repetition at other pitches) and which recurs often in the course of the design. It is not to be misunderstood with a figuring tune, which is a style of a song popularized by and mostly limited to early American music and West Gallery music. A fugue usually has three main areas: an exposition, a story, and a final admission that includes the return of the issue in the fugue's remedy key. Some fugues have a recapitulation.

To learn more about fugue, refer to:

brainly.com/question/1132239

#SPJ4

The complete question is:

The ________ is a keyboard form based on the principle of voices imitating each other.

a. fugue

b. prelude

c. suite

d. toccata

7 0
1 year ago
What is one way programmers notify users of program updates? Email messages Magazine advertisements Public service announcements
Vikki [24]
I believe the answer is email notices
3 0
3 years ago
If you're looking to install Gigabit Ethernet, what cabling system would you use?
Vitek1552 [10]

Answer:

The correct answer to the following question will be option c. Cat-6.

Explanation:

Cat-6: A standard version of twisted pair cable for physical layer of networking and for Ethernet is, Cat-6 (Category 6) cable.

  • Cat-6 will be adaptable with the Category 5/5e and 3 standard of cables, and the standard specifies the performance of cable compared to 100 MHz up-to 250MHz for Cat 5/5e.
  • So, if you are looking for the best cabling system to use while installing the Gigabit Ethernet, Category 6 will be the suitable one.
6 0
3 years ago
Other questions:
  • Use the drop-down menus to complete the statements about using section breaks in a document
    9·1 answer
  • If an improvement creates no significant change in a product’s performance, then it is a(n) ? a0 design improvement.
    6·1 answer
  • Which best explains why magnets can push on or pull other magnets without touching them?
    9·1 answer
  • The animation industry is solely reliant on 3-D modeling and 3-D virtualization to create the animated movies in the cinemas.
    5·1 answer
  • Why did latex replace wax?
    7·1 answer
  • What can a scientist do if he repeats and experiment and gets diffrent results?
    5·1 answer
  • 6.8 Code Practice<br> please can have some help please
    8·1 answer
  • What is one way object-oriented programming differs from procedural programming?
    15·1 answer
  • Write a pseudocode for the logic of a program that accepts five numbers from a user and displays one of the following messages:-
    8·1 answer
  • Which of the following declares an abstract method in an abstract Java class?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!