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
Your boss wants to utilize some sort of cloud storage for his files so that all of his
Valentin [98]

Well, if he's using Google Drive or OneDrive it shows up in the main menu so My best guess would be Local Profile

4 0
3 years ago
Read 2 more answers
A bookmarking site is a website that enables members to manage and share media such as photos, videos, and music. true or false
uysha [10]
The answer is false.
4 0
3 years ago
After Lola gave her friend the password to a protected website, her friend was able to remember it only long enough to type it i
Naily [24]

Answer:

Short term memory

Explanation:

Is the capacity an individual has to hold on to a small amount of information for a short period of time without altering it, it is used to remember information like phone numbers, passwords etc. It is also known as primary or active memory.

If short time memories is not rehearsed, they don't last and are easily forgotten, they actually last for about 20-30 seconds.

Aspects of short term memory :

1. Limited capacity : in a short term memory at most 7 items can be stored at a time.

2. Limited capacity : information is short lived and can be lost through distraction and with time.

3. Encoding.

4 0
3 years ago
How I can learn writing code?
slavikrds [6]

A good website to learn coding is called Lynda.com. It costs money but its well worth it!

3 0
2 years ago
Read 2 more answers
If an individual receives 1.8 mGy while standing 4 ft from a source of radiation for 2 minutes, which of the following option(s)
erastovalidia [21]

Answer:

The answer is letter B.

Explanation:

The option that will most effectively reduce her or his radiation exposure to that source is Standing 8 ft from the source for 2 minutes.

6 0
3 years ago
Other questions:
  • You took a fantastic photograph that you want to use in the report you're writing using DTP software. To import the photo into y
    6·2 answers
  • Conceptual note-taking is the act of
    15·1 answer
  • Write a complete program to read two integers and display the number of integers that lie between them, including the integers t
    12·1 answer
  • Which of the following is NOT essential for individuals to have to build their own web page?
    9·1 answer
  • To have the most impact when using email, you should structure your messages so that
    5·1 answer
  • 10. Question
    15·1 answer
  • Fedora operating system
    9·1 answer
  • In cell K8, create a formula using the SUM function that calculates the total of range D17:D20 and subtracts it from the value i
    7·1 answer
  • Write a program that repeatedly takes integers from the user as long as he
    7·1 answer
  • which of the following devices and and receive information from other device? a parallel port B serial port C video port d both
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!