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
IBM’s system that is built on the middle ground approach to AI.
Norma-Jean [14]

Answer:

IBM Watson is AI for business. Watson helps organizations predict future outcomes, automate complex processes, and optimize employees' time.

Explanation:

6 0
3 years ago
A chart generated in Microsoft Excel can be plugged into a presentation authored used PowerPoint?
zlopas [31]

The answer is True.  A chart generated in Microsoft Excel can be plugged into a presentation authored used Powerpoint.    You can copy it from Excel ( by right-clicking on the chart and select copy) and then Paste it in Power Point.  Or, you can save it and import it as an image.

8 0
3 years ago
While recording a voice, if the narration is large,it is better to make a :a)a linked object b)an embedded object c)none d)does
goldenfox [79]

Answer:

c)none

Explanation:

Automatic updates can be a great problem in the case of the linked object and an embedded object. Hence, "a" and "b" are not the correct options, and since there is an effect, the d. the option is also not correct, as it does affect. And hence none of these options are correct. And the correct option is c) none.

4 0
3 years ago
1) These are operators that add and subtract one from their operands.
adoni [48]

Answer:

1) B (++ and --)

2) A (1 2 3 4 5)

Explanation:

In the first question, the operators ++ and -- are used in almost all programming languages for adding  and subtracting  1 respectively from an operand.

In the second question using a while statement the numbers 1-5 is printed out because the variable n=1 is increased by 1 after each iteration.

7 0
3 years ago
What command should you use to rearrange parts of files on the drive so they are contiguous?
Sunny_sXe [5.5K]
<span>What command should you use to rearrange parts of files on the drive so they are contiguous? Answer = Defrag</span>
3 0
4 years ago
Other questions:
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    11·2 answers
  • Application partitioning gives developers the opportunity to write application code that can later be placed on either a client
    7·1 answer
  • True or False. A modern programming EXE provides a text editor, a file manager, a compiler, a linker and loader, and tools for d
    9·1 answer
  • You notice that it’s very easy to confuse medications at the community health center where you’re working. They are lined up on
    10·1 answer
  • Define the terms candidate key and primary key. Explain the difference between a primary key and a candidate key.
    9·1 answer
  • Why does a CPU need Thermal Grease?
    14·1 answer
  • Which is a method used with arrays?<br><br> find<br><br> index<br><br> insert<br><br> sort
    8·1 answer
  • Which image-editing tool can be used to help remove spots and other marks from an image?
    13·1 answer
  • Write javascript code for the form that appears in the image below. you are expected to add validation to the name field, email
    10·2 answers
  • Taylor has to write a letter denying a customer's request for a free replacement on her two-year-old business laptop, which is p
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!