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
Travka [436]
3 years ago
14

Write a program to read 10 integers from an input file and output the average, minimum, and maximum of those numbers to an outpu

t file. Take the name of the input file and output file from the user. Make sure to test for the conditions 1. if the count of numbers is less than 10 in the input file, then your average should reflect only for that many numbers 2. if the count of numbers is more than 10 in the input file, then your average should reflect only for ten numbers only.
Computers and Technology
1 answer:
umka21 [38]3 years ago
3 0

Answer:

#include <iostream>

#include <climits>

#include<fstream>

using namespace std;

int main ()

{

fstream filein;

ofstream fileout;

string inputfilename, outputfilename;

// ASk user to enter filenames of input and output file

cout<<"Enter file input name: ";

cin>>inputfilename;

cout<<"Enter file output name: ";

cin>>outputfilename;

// Open both file

filein.open(inputfilename);

fileout.open(outputfilename);

// Check if file exists [Output file will automatically be created if not exists]

if(!filein)

{

cout<<"File cannot be opened"<<endl;

return 0;

}

int min = INT_MAX;

int max = INT_MIN; //(Can't use 0 or any other value in case input file has negative numbers)

int count = 0; // To keep track of number of integers read from file

double average = 0;

int number;

// Read number from file

while(filein>>number)

{

// If min > number, set min = number

if (min>number)

{

min = number;

}

// If max < number. set max = number

if(max<number)

{

max = number;

}

// add number to average

average = average+number;

// add 1 to count

count+=1;

// If count reaches 10, break the loop

if(count==10)

{

break;

}

}

// Calculate average

average = average/count;

// Write result in output file

fileout<<"Max: "<<max<<"\nMin: "<<min<<"\nAverage: "<<average;

// Close both files

filein.close();

fileout.close();

return 0;

}

You might be interested in
True or False: clicking ads and pop-ups like the one below could expose your computer to malware.
Ratling [72]

True, clicking ads and pop-ups can expose your computer to malware.

3 0
2 years ago
Read 2 more answers
Adrian wants to run a digital movie clip that his friend shared with him through email. His system has 2 GB of RAM and 20 GB of
bogdanovich [222]

Answer:

Adrian requires a high speed internet connection and a codec player to download and run movie on his system.

Explanation:

There are some basic requirements of the computers that, can be used to watch the movie on the computer.

1. RAM

2. Storage space to store the movie

3. High Speed Internet: As the movie is on the internet, to download it from internet, bandwidth and speed of internet is required.

4. Video Codec Player is required to play a digital movie on laptop or system.

3 0
2 years ago
give an example of a technical issue you were not able to resolve on your first attempt. What troubleshooting steps did you take
erastovalidia [21]
One technical issue I had was on Windows 8.1, with the charm menu not working. The troubleshooting steps to fix it was I did CTRL+SHIFT+ESC to open task manager. I then found Windows Explorer and clicked "Reload." Then everything was fine.

Hope This Helped!
6 0
2 years ago
Which program will have the output shown below?
kumpel [21]

for count in range(5, 8):

   print(count)

This will produce.

5

6

7

I hope this helps!

5 0
2 years ago
How to bypass a Lightspeed and Rocket Filter blocked website without being a admin and without downloading extensions? Must incl
AVprozaik [17]

You really cant without being admin. Calm yaself child

6 0
2 years ago
Other questions:
  • This activity will help you meet these educational goals:
    7·2 answers
  • You are building a gaming computer and you want to install a dedicated graphics card that has a fast gpu and 1gb of memory onboa
    15·2 answers
  • Write the definition of a method, oddsMatchEvens, whose two parameters are arrays of integers of equal size. The size of each ar
    10·1 answer
  • You are system administrator with hundreds of host workstations to manage and maintain. You need to enable hosts on your network
    14·1 answer
  • Which documents might an employer expect to find in a career portfolio?
    15·2 answers
  • Please help thank you !!!
    7·2 answers
  • 1
    7·1 answer
  • Can Algorithms Be Used Again?
    8·1 answer
  • What is the web page path on the web server for the URL:
    12·1 answer
  • Besides a backup technician, who else would have encrypted backup passwords?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!