Write a complete C++ program to read data from a file named Datal.txt (see content of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a complete C++ program to read data from a file named Datal.txt (see content of file below) and to calculate and display the average of each group of numbers in this file. The data is arranged in the file so that each group of numbers is preceded by the number of data items in that group. Therefore the first number in the file, 5, indicates that the next five numbers are in a group. The number 4 indicates that the following four numbers are a group, and the 6 indicates that the last six numbers are a group. (Hint: Use a nested loop. The outer loop should terminate when the end of the file is encontered. Content of file Datal.txt 5 96 87 78 93 21 4 92 82 85 87 6 72 69 85 75 81 73 Your program should produce the following output to the screen given the data in Data 1.txt. CC:\Windows\system32\cmd.exe Numbers read from file: 96 Average 275 Numbers read from file: 92 Average 86.5 Numbers read from file: 72 Average = 75.8333 All done!! 111 87 82 69 78 85 85 93 87 75 21 81 73 X Write a complete C++ program to read data from a file named Datal.txt (see content of file below) and to calculate and display the average of each group of numbers in this file. The data is arranged in the file so that each group of numbers is preceded by the number of data items in that group. Therefore the first number in the file, 5, indicates that the next five numbers are in a group. The number 4 indicates that the following four numbers are a group, and the 6 indicates that the last six numbers are a group. (Hint: Use a nested loop. The outer loop should terminate when the end of the file is encontered. Content of file Datal.txt 5 96 87 78 93 21 4 92 82 85 87 6 72 69 85 75 81 73 Your program should produce the following output to the screen given the data in Data 1.txt. CC:\Windows\system32\cmd.exe Numbers read from file: 96 Average 275 Numbers read from file: 92 Average 86.5 Numbers read from file: 72 Average = 75.8333 All done!! 111 87 82 69 78 85 85 93 87 75 21 81 73 X
Expert Answer:
Answer rating: 100% (QA)
C program to read data from a file named Data1txt and calculate and display the average of each grou... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
In Python use a loop to read data from a text file which containing students' names and exam scores. The program should calculate the exam average for each student, determine the appropriate letter...
-
What is a file? How can we read data from a file in Java?
-
Discuss the mechanism used to read data from or write data to disk.
-
1- The z-axis carries filamentary current of 10. A. Find Hat (-3,74,0) ? p= = = 2- The Y-axis carries filamentary current of 10 A. Find H at (-3,4,1) ? p= ,= = p= , = H p= 3- The X-axis carries...
-
1. What are the major changes between this plan and the way ORION has managed projects in the past? 2. How well do you believe these changes deal with the problems identified in Part A? 3. Who is...
-
Where is the cash paid during the year to satisfy a company s debt found?
-
What conditions for the binomial distribution, if any, fail to hold in the following situations? (a) For each of a company's eight production facilities, record whether or not there was an accident...
-
LeMoyne Manufacturing Inc.s joint cost of producing 2,000 units of Product X, 1,000 units of Product Y, and 1,000 units of Product Z is $50,000. The unit sales values of the three products at the...
-
The figure shows the chain drive of a bicycle. How far will the bicycle move if the pedals are rotated through 180? Assume the radius of the bicycle wheel is 13.2 inches. The bicycle will travel...
-
Putt Corporation acquired 70 percent of Slice Companys voting common stock on January 1, 20X3, for $158,900. Slice reported common stock outstanding of $100,000 and retained earnings of $85,000. The...
-
Case Study 1.3: Entering Through the Side Door: The College Admissions Bribery Scandal. What should happen to students admitted under the bribery scheme? Should admissions standards for athletes (or...
-
Ms. C is a 25% shareholder of Chow Corporation, a foreign corporation. On the day of the transition tax measurement. Chow has $30 million in and $90 million of other assets. Chow's foreign E&P on...
-
Today is t= 0. Derivative Y is a combination of a 1-year European long call and 1-year European long put, both with strike prices of $100. The payout of the derivative is thus max(S-100, 100-S) at t...
-
A plane lands on a runway with a speed of 11.5m/s, moving east and it slows to stop in 11.0s. What is the magnitude ( in m/s 2 ) and direction of the planes average acceleration during this time...
-
The current US Dollar to Yen exchange rate is Mo 110. The CCIR US rate is 4% and the CCIR Japanese rate is 2%. Banco Santander is currently willing to offer a one-month forward contract (assuming...
-
On January 1, 20x3, Big Co (a public company reporting under IFRS) purchased 30% of the common shares of Small Co for $200,000, giving Big Co significant influence over Small Co. On January 1, 20x3,...
-
If a stock consistently goes down (up) by 1.45% when the market portfolio goes down (up) by 1.06%, then calculate its beta.
-
2.) Find the Laplace transform of f(t) 7e-St cos 2t +9 sinh2 2t. Use Laplace Table. %3D
-
Write a program that displays the calendar for the current month. You can use the Prior and Next buttons to show the calendar of the previous or next month. Display the dates in the current month in...
-
Write a program that displays a checkerboard in which each white and black cell is a Rectangle with a fill color black or white, as shown in Figure 14.44c. (c)
-
Use nested loops that display the following patterns in four separate programs: Pattern B 12 3 4 5 6 2 3 4 5 123 4 Pattern D 1 2 3 4 5 6 12 3 4 5 123 4 Pattern A Pattern C 2 1 3 2 1 4 3 2 1 5 4 3 2 1...
-
A single stage single acting air compressor has intake pressure 1 bar and delivery pressure 10 bar. The compression and expansion follow the law \(\mathrm{pV}^{1.3}=\) constant. The piston speed and...
-
Find the expression for volumetric efficiency of the reciprocating compressor.
-
An air compressor has eight stages of an equal pressure ratio of 1.4. The flow rate through the compressor and the overall efficiency are 40 \(\mathrm{kg} / \mathrm{sec}\) and \(92 \%\),...
Study smarter with the SolutionInn App