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
How can i get google assistant on my lava iris 820 smartphone easily???? ​
Free_Kalibri [48]

Google assistant on my lava iris 820 smartphone in the following way.

Explanation:

Google Assistant on your smartphone, here’s a complete ready to use guide

How to download and install Google Assistant

  • Most of the Android smartphones today come with Google Assistant pre installed and if it is not there.You can download it from Google Play Store.Apple iphone/ipad user installed it fro the App store.

How to set up google assistant .

  • Turn the Google Assistant on or off
  • On your Android phone or tablet, touch and hold the Home button or say "OK Google" or "Hey Google."
  • In the bottom right, tap .
  • In the top right, tap your Profile picture or initial Settings. ...
  • Under "Assistant devices," select your phone or tablet.
  • Turn Google Assistant on or off.

Link your voice

To use Voice Match, you must link a Google Account to the Google Assistant device. If you have multiple Google Accounts, you can choose which account you want to use.

Open the Google Home app Google Home.

At the bottom, tap Home Home and then Settings Settings.

Under “Google Assistant services,” tap More settings.

Tap Assistant and then Voice Match and then Add devices.

Follow the steps.

When you link your voice and use the Google Assistant in US English, the Google Assistant will automatically acknowledge when you ask it for something politely.

5 0
3 years ago
Tech A says that gasoline vapors are lighter than air, so inspection pits do not have a fire hazard like above ground hoists. Te
Elden [556K]

Answer:

Tech B is correct.

Explanation:

First, It is international best practice never to exceed the lifting capacity of any hoist. To do so would expose those involved to risks that may prove to be fatal.

Second, research has shown that gasoline vapors, as well as vapor from almost all other flammable or ignitable liquids or substances, are heavier than air.

More specifically, Gasoline produces flammable vapors that are heavier than air by 3 to 4 times. This means they can travel for great distances along the ground. Worst still, inspection pits are must be kept free from gas vapors because they tend to accumulate in low or enclosed spaces.

Both technicians should and must observe all occupational, health, and safety rules and guidelines stipulated and required for their industry/practice.

Cheers

4 0
2 years ago
Waterpower was first harvested by ancient societies using
Maslowich
Not sure why this question is in Computers and Technology...

Answer should be c.
6 0
3 years ago
In addition to the four primary computer operations, today's computers almost always perform ____ functions.
NeX [460]

The correct answer is:    " information "  .

_________________________

<u>Note</u>:  In addition to the [4 (four) "primary computer operations" —  which are:  

 "input, processing, output, and storage" ] — today's computers almost always perform <u>  information  </u> functions.

_________________________

5 0
2 years ago
What is operating system​
iren [92.7K]

Answer:

It's simply a software that runs a computer's basic tasks, or functions, such as scheduling, running applications, and controlling peripherals.

3 0
3 years ago
Read 2 more answers
Other questions:
  • An unwanted 'explosion' of inbox messages is called​
    8·2 answers
  • Read the scenario below. Explain why this is not fair use of copyright materials. What should you do instead of using the entire
    10·1 answer
  • Which method deletes a footer from a document?
    13·2 answers
  • [Java] Using the comparable interface
    13·1 answer
  • What is the Documenter?
    10·1 answer
  • ServletConfig defines a set of methods that a servlet uses tocommunicate with its servlet container.
    5·1 answer
  • Run the browser checker to see that the computer you are using now is set up for WileyPLUS. Which of the following browser funct
    15·1 answer
  • An IT professional with a customer-service
    13·1 answer
  • Which option is an example of an algorithm that is used in daily life?
    8·1 answer
  • Write l for law of enrtia,ll for law of Acceleration and lll for law of enteraction.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!