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
dem82 [27]
4 years ago
10

If you have downloaded this book’s source code from the companion Web site, you will find a file named Random.txt in the Chapter

05 folder. (The companion Web site is at www.pearsonhighered/gaddis.) This file contains a long list of random numbers. Copy the file to your hard drive and then write a program that opens the file, reads all the numbers from the file, and calculates the following: A) The number of numbers in the file B) The sum of all the numbers in the file (a running total) C) The average of all the numbers in the file The program should display the number of numbers found in the file, the sum of the numbers, and the average of the numbers. Prompts And Output Labels: Print each of the above quantities on a line by itself, preceding by the following (respective) labels: "Number of numbers: ", "Sum of the numbers: ", and "Average of the numbers: ".
Computers and Technology
1 answer:
Lorico [155]4 years ago
6 0

Answer:

Check the explanation

Explanation:

Here is the code for you:

#include <iostream>

#include <fstream>

using namespace std;

int main ()

{

int aNumber=0;

int numbers=0;

double sum=0.0;

double average=0.0;

ifstream randomFile;

randomFile.open("Random.txt");

if (randomFile.fail())

cout << "failed to read file.";

else

{

while (randomFile >> aNumber)

{

numbers++;

sum+=aNumber;

}

if (numbers>0)

average = sum/numbers;

else

average=0.0;

cout << "Number of numbers: " << numbers << "\n";

cout << "Sum of the numbers: " << sum << "\n";

cout << "Average of the numbers: " << average;

}

randomFile.close();

return 0;

}

You might be interested in
teve wants to use Google Display Ads to reach new customers who are looking to purchase products similar to his. Which audience
Andrew [12]

Answer:

In-Market audiences.

Explanation:

Steve intends for using Google display advertising to achieve new clients seeking to acquire identical items to himself. Form of in-market audience should Steve try to achieve his marketing objective.

In-market audiences seem to be a method of connecting with customers who regularly study or compare goods and facilities through Google Display Platform publishers and affiliate websites

5 0
4 years ago
You defined a shoe data type and created an instance.
Assoli18 [71]

Answer:

myShoe.type = 'sneaker'

Explanation:

type is a field of the class shoe. The myShoe object which is an instance of the class shoe has the field type also.

To assign a value to type filed of the object myShoe, reference the object then the field as such;

   myShoe.type = "sneaker"

7 0
2 years ago
Please help with this:
Tanzania [10]

Answer:

I'm not gonna give you the answer. I want you to think about this what is math, what is science, how does it help the world, and etc. These are some example questions to help.

Explanation:

5 0
3 years ago
Write a program that inputs numbers and keeps a
rjkz [21]

I've included my code in the picture below. Best of luck.

3 0
3 years ago
Each time the enter key is pressed, word creates a new paragraph. (points : 2) true false
ludmilkaskok [199]
Your answer would be true
6 0
3 years ago
Other questions:
  • Regarding an intrusion detection system (IDS), stateful matching looks for specific sequences appearing across several packets i
    9·1 answer
  • How to go to a website with an ip address?
    15·1 answer
  • The gaining of unauthorized access to data in a<br> system or computer:
    11·1 answer
  • _____ is a systems development technique that produces a graphical representation of a concept or process that systems developer
    11·1 answer
  • Peace is a fruit of the Spirit that comes from _______ .
    11·1 answer
  • What is used to accurately position objects on the slide using a single horizontal and vertical line that intersects in the cent
    5·2 answers
  • Which of the following is NOT a reason we use subprograms?
    7·1 answer
  • What are some other possible causes of an overheating laptop
    7·1 answer
  • Why is it important for organizations to make strong commitment to Cloud at scale?
    14·1 answer
  • What do you mean by Graphics editing​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!