Home / Expert Answers / Computer Science / c-1-prompt-read-a-file-name-and-open-the-file-2-do-a-priming-read-and-make-a-while-loopto-if-pa935

(Solved): C++ 1. Prompt \& read a file name and open the file. 2. Do a priming read and make a while loopto If ...



C++



1. Prompt \& read a file name and open the file.
2. Do a priming read and make a while loopto
If you do not know what primin
Example I/O
Enter a file name: nums.dat
With 10 numbers, the average is \( 32.23 \). With 20 numbers, the average is \( 36.14
1. Prompt \& read a file name and open the file. 2. Do a priming read and make a while loopto If you do not know what 'priming read' is, then look it up in the text. a. Read in the numbers, b. Sum them up, and c. Count how many there are. words, every 10 numbers that you read in you print the average. See the example. 3. Finally... after the loop, calculate the average and print it. Use fixed and setprecision(2) for the average but not the count of numbers. Read in double numbers to average; Usually you use ints when counting. Your loop should look something like this: I/ read a number while ( your-ifstream-variable) \{ I/ sum number If count if (count \& 10 ) I/ then cout "With xxx numbers, the average is YYYYY." I/ read a number 1 cout final average output Example I/O Enter a file name: nums.dat With 10 numbers, the average is . With 20 numbers, the average is . with 30 numbers, the average is . with 40 numbers, the average is . With 50 numbers, the average is . There are 54 numbers in the file with an average of . Enter a file name: nums2. dat With 10 numbers, the average is . There are 19 numbers in the file with an average of . Enter a file name: nums 3 . dat There are 1 numbers in the file with an average of . Enter a file name: nums4.dat There are 4 numbers in the file with an average of .


We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe