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
In which state of matter is there no particle motion?
kiruha [24]
Solid is your answer for the day
6 0
2 years ago
Find an example of a print or Internet ad that includes images and text, and then answer
WARRIOR [948]

4. Find an example of a print or Internet ad that includes images and text, and then answer the following questions about it.

           a. Describe the ad. (1-3 sentences. 1.0 points)

Mcdonald's all day breakfast. It shows their breakfast items, with high-quality images.

b. What do you think this ad's marketing message is? (1-5 sentences. 2.0 points) TIP: Does it use a specific desire or fear, or does it try to show how the product is a need or how it solves a problem?

They use desire because they show their delicious looking food, and the customers are wanting it.

c. Is the ad trying to get people to do something? If so, what is it trying to get people to do? If it isn't trying to get people to do something, what do you think the point of the ad is? (1-5 sentences. 2.0 points)

The ad is trying to get people to stop at Mcdonalds and buy their breakfast items

           d. Do you think this ad is effective? Why or why not? (1-5 sentences. 2.0 points)

Yes I think this ad is effective because it is showing high quality images of their breakfast items that encourage people to stop by and try their products.

3 0
3 years ago
Write an if/else statement that assigns 1 to the variable fever if the variable temperature is greater than 98.6; otherwise it a
klio [65]

Answer:

temperature = int(float(input("Enter temperature: ")))

fever = 0

if temperature > 98.6:

   fever +=1

else:

   fever = 0

print(fever)

Explanation:

3 0
2 years ago
When media is used to communicate with a very large audience, it is referred to as media.
Sophie [7]

Answer:

mass media

Explanation:

6 0
3 years ago
Read 2 more answers
Which company invented the Six Sigma process?
horsena [70]

Answer:

Motorola

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • 3) Write a program named Full_XmasTree using a nested for loop that will generate the exact output. This program MUST use (ONLY)
    6·1 answer
  • Name five services available at banks.
    7·1 answer
  • Page UND
    8·1 answer
  • You have developed a prototype of a software system and your manager is very impressed by it. She proposes that it should be put
    5·1 answer
  • Effective presentations vary the color scheme on each slide.
    7·2 answers
  • You are responsible for the administration of your Windows Server 2016 DNS server, which is installed on a domain controller as
    8·1 answer
  • Which branch of science helps avoid or minimize stress-related injuries at workplace?
    14·1 answer
  • Which item is not part of a college application
    11·1 answer
  • ________ helps in determining the cause of a security threat in an incident response plan. Question 7 options: A) Restricting sy
    5·1 answer
  • To speed up data retrieval, more vehicles will be upgraded to cellular connections and be able to transmit data to the ETL proce
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!