Question

4246833550117072547935996346570614628282896249299694382843739260590315429338342271771989644872777253987091366830036895704812323334674665142712254869548645663758 388607247425307793173619184328910741943265649447806891730371351710239454963062485955757841967

4246833550117072547935996346570614628282896249299694382843739260590315429338342271771989644872777253987091366830036895704812323334674665142712254869548645663758

38860724742530779317361918432891074194326564944780689173037135171023945496306248595575784196737793230994544062732453853911983930542834116640659705931978307

6743872274692573271830778574985139872911626373567686565753253351151942725967431108192833845828875438494691021075922258942394750731414169901592763656411360

625538549484596426033512928373752159722349200669485282735541000419939901789128468729894649484808422311618814515

The file named Random.txt contains a long list of random numbers. Download the file to your system, then write a program that opens the file, reads all the numbers from the file, and calculates the following:

  1. The number of numbers in the file
  2. The sum of all the numbers in the file (a running total)
  3. 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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

save those numbers in a text file "Random.txt" in the same folder where you will save this code

1 2 3 #include <iostream> #include <fstream> using namespace std; 4 5 int main() 6 { 7 8 9 = ifstream f; f.open(Random.txt)

#include <iostream>

#include <fstream>

using namespace std;

int main()

{

    ifstream f;

    f.open("Random.txt");

    int count = 0;  //to store count

    double sum = 0; //to store sum

    double var = 0; //to read from file

    while (f >> var)

    {

        count++;

        sum += var;

    }

    cout << "The number of numbers in the file is: " << count;

    cout << "\nThe sum of all the numbers in the file: " << sum;

    cout << "\nThe average of all the numbers in file is: " << sum / count;

}

//PLEASE LIKE IT RAISE YOUR THUMBS UP
//IF YOU ARE HAVING ANY DOUBT FEEL FREE TO ASK IN COMMENT SECTION

Add a comment
Know the answer?
Add Answer to:
4246833550117072547935996346570614628282896249299694382843739260590315429338342271771989644872777253987091366830036895704812323334674665142712254869548645663758 388607247425307793173619184328910741943265649447806891730371351710239454963062485955757841967
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am in C++ programming, I need help with this assignments. The answer in this assignments...

    I am in C++ programming, I need help with this assignments. The answer in this assignments when I look for it it doesn't work in my visual studios. Can you please help me? I hardly have C in the class, if I fail I will fail the whole class and repeat this class again.   The file named Random.txt contains a long list of random numbers. Download the file to your system, then write a program that opens the file, reads...

  • I need #5 done i cant seem to understand it. it must be written in c++...

    I need #5 done i cant seem to understand it. it must be written in c++ 4. Numeric Processing Write a program that opens the file "random.txt", reads all the numbers from the file, and calculates and displays 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 numFile.cpp Notes: Display the average of the numbers showing...

  • 1.Write a python program that writes a series of random numbers to a file named random.txt....

    1.Write a python program that writes a series of random numbers to a file named random.txt. Each random number should be in the range of 1 through 300. The application should let the user specify how many random numbers the file will hold. 2. Write another program that reads the random numbers from the random.txt file, displays the numbers, then displays the following data: I. The total of the numbers II. The number of random numbers read from the file

  • these numbers are from Random.txt file since i couldn't upload the file 42 468 335 501...

    these numbers are from Random.txt file since i couldn't upload the file 42 468 335 501 170 725 479 359 963 465 706 146 282 828 962 492 996 943 828 437 392 605 903 154 293 383 422 717 719 896 448 727 772 539 870 913 668 300 36 895 704 812 323 334 674 665 142 712 254 869 548 645 663 758 38 860 724 742 530 779 317 36 191 843 289 107 41 943...

  • C++ 3. Write a program that reads integers from a file, sums the values and calculates...

    C++ 3. Write a program that reads integers from a file, sums the values and calculates the average. a. Write a value-returning function that opens an input file named in File txt. You may "hard-code" the file name, i.e., you do not need to ask the user for the file name. The function should check the file state of the input file and return a value indicating success or failure. Main should check the returned value and if the file...

  • This assignment assumes you have completed Programming Assignment 6, Random Number File Writer. Write another program...

    This assignment assumes you have completed Programming Assignment 6, Random Number File Writer. Write another program that reads the random numbers from the random.txt file created in Programming Assignment 6, display the numbers, and then display the following data: The total of the numbers. The number of numbers read from the file. Please program in python

  • a. Provide me with your code file, output file and the text file. 1. Create a...

    a. Provide me with your code file, output file and the text file. 1. Create a file with a series of integers. Save it as numbers. txt. Write a program that reads all the numbers and calculates their sum . 2. Create a file having different integers than the first one. Save it as numbers1. txt . Write a program that reads all the number and calculates their average. Important: The two files that you are creating will contain different...

  • I need help in Python. This is a two step problem So I have the code...

    I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...

  • Please use Python for this program Random Number File Writer Write a program that writes a...

    Please use Python for this program Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range 1 through 500. The program should let the user specify how many random numbers to put into the file. The name of the file to write to should be 'random.txt'. Submit the random.txt file generated by your program with the assignment. Sample program execution: Python 3.4.3 Shell Eile Edit...

  • PLEASE HELP C++ some of the content in random.txt Program #2 This problem is a modification...

    PLEASE HELP C++ some of the content in random.txt Program #2 This problem is a modification of Problem 24 on page 302 of the Gaddis text with two small additions. (A scan of this problem can be found on the last page of the assignment.) In this assignment, your program will read in a list of random numbers from an input file, random. txt (found on eLearning in the "Homework Input Files" folder), and calculate the following statistics on those...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT