Write a C++ program that opens a file named data.txt which contains data written in three...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C++ program that opens a file named data.txt which contains data written in three lines. Each line starts with a letter followed by three double floating- point values. The program should output the data in table format such that lines are ordered in the table alphabatically according to the letters they start with. If the letter is an uppercase, it must be converted to its equivalent lowercase letter. All letters must be displayed in lowercase format. Notice that the width of the first column in the table (which contains the letter) is 5 and it is aligned to the left. All remaining columns have width of 10 and their data is aligned to the right. Also Notice, that all the numbers in the table must be displayed with exactly three digits to the right of the decimal point. After prinitng the table, the program must display the following statistics values (computed for all floating point values read from the file) on one line with exactly one space between each two of them, as follows: Average Standard deviation Maximum Minimum Statistics values must also be displayed with exactly three digits to the right of the decimal point. Equation for computing the standard deviation is: Σ(; – μ)2 N o standard deviation N = number of values x₁ = each value from the set average of values μl = IMPORTANT NOTES • Do not add any cout statements except for the final outputs as shown in the sample cases. Do not add "Enter the file name", "the average =" or any similar prompts. The width of each table column is given in the problem statement. Do not add any extra spaces. When printing the statistics numbers on the last line, print exactly one space between each two numbers. • Your program must produce correct results for any 1/0 problem statement. Do not add any extra spaces. • When printing the statistics numbers on the last line, print exactly one space between each two numbers. • Your program must produce correct results for any possible values for the letters and the floating point numbers in the file data.txt. • You can include other libraries in your code if needed. Program Input: The data that is read from the file data.txt. Program Output: The data in table format, then statistics are displayed on the console as shown in the sample case. Sample Test Case Input: Suppose the contents of the file data.txt are as follow: e 1.342 2.9437 2.371 B 0.53214 4.3213 2.7432 G 3.7654 4.6432 2.34215 Output: b e g 2.778 1.262 4.643 0.532 0.532 1.342 3.765 4.321 2.944 4.643 1 #include <iostream> 2 using namespace std; 3 4 5 6 7 8 9 10 11 12 } int main() { // Your code starts here // Your code ends here return 0; 2.743 2.371/1 2.342 Write a C++ program that opens a file named data.txt which contains data written in three lines. Each line starts with a letter followed by three double floating- point values. The program should output the data in table format such that lines are ordered in the table alphabatically according to the letters they start with. If the letter is an uppercase, it must be converted to its equivalent lowercase letter. All letters must be displayed in lowercase format. Notice that the width of the first column in the table (which contains the letter) is 5 and it is aligned to the left. All remaining columns have width of 10 and their data is aligned to the right. Also Notice, that all the numbers in the table must be displayed with exactly three digits to the right of the decimal point. After prinitng the table, the program must display the following statistics values (computed for all floating point values read from the file) on one line with exactly one space between each two of them, as follows: Average Standard deviation Maximum Minimum Statistics values must also be displayed with exactly three digits to the right of the decimal point. Equation for computing the standard deviation is: Σ(; – μ)2 N o standard deviation N = number of values x₁ = each value from the set average of values μl = IMPORTANT NOTES • Do not add any cout statements except for the final outputs as shown in the sample cases. Do not add "Enter the file name", "the average =" or any similar prompts. The width of each table column is given in the problem statement. Do not add any extra spaces. When printing the statistics numbers on the last line, print exactly one space between each two numbers. • Your program must produce correct results for any 1/0 problem statement. Do not add any extra spaces. • When printing the statistics numbers on the last line, print exactly one space between each two numbers. • Your program must produce correct results for any possible values for the letters and the floating point numbers in the file data.txt. • You can include other libraries in your code if needed. Program Input: The data that is read from the file data.txt. Program Output: The data in table format, then statistics are displayed on the console as shown in the sample case. Sample Test Case Input: Suppose the contents of the file data.txt are as follow: e 1.342 2.9437 2.371 B 0.53214 4.3213 2.7432 G 3.7654 4.6432 2.34215 Output: b e g 2.778 1.262 4.643 0.532 0.532 1.342 3.765 4.321 2.944 4.643 1 #include <iostream> 2 using namespace std; 3 4 5 6 7 8 9 10 11 12 } int main() { // Your code starts here // Your code ends here return 0; 2.743 2.371/1 2.342
Expert Answer:
Answer rating: 100% (QA)
include include include include include int main stdifstream inputFiledatatxt stdvector letters stdv... View the full answer
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
At the beginning of Year 4 , Able Company had the following portfolio of investments in trading securities ( all of which were acquired at par value ) : Security Cost 1 / 1 / Y 4 Fair Value A $ 2 0 ,...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Goodwill impairment tests are carried out annually. During 2014, goodwill impairment was determined to be $26,000 on the parents share of goodwill and $5,000 on the NCI share. In 2016, impairment in...
-
Select the reasons why most professional telescopes are reflectors rather than refractors. A mirror can collect light more efficiently than a lens. Reflecting telescopes have shorter focal lengths...
-
Who gains and who loses when a country imposes a tariff or a quota on imports of a good?
-
Name the following compounds and assign oxidation states to the halogens in them: (a) Fe(ClO3)3 (b) HClO2 (c) XeF6 (d) BrF5 (e) XeOF4 (f) HIO3.
-
The balance sheet of Oriental Rug Company at December 31, 2008, included the following stockholders' equity: During 2009, Oriental Rug completed the following selected transactions: Requirements 1....
-
Five months before the new 2002 Lexus ES hit showroom floors, the company's U.S. engineers sent a test report to Toyota City in Japan: The luxury sedan shifted gears so roughly that it was "not...
-
What are the five personal qualities that Baker states employers seek? 2. What are the three main types of proposals? 3. What was one of the most important things you found that was new or you were...
-
A tree farm harvests a variety of trees that are sold to garden centres. In 20X5, the company was created and they acquired 1,500 immature blue spruce trees and 300 mature blue spruce trees. Each...
-
A wood pipe having an inner diameter of 3 ft. is bound together using steel hoops having a cross sectional area of 0.2 in 2 . The allowable stress for the hoops is allos = 11.4 ksi. Determine the...
-
Christmas Anytime issues $810,000 of 7% bonds, due in 20 years, with interest payable semiannually on June 30 and December 31 each year. Calculate the issue price of a bond and complete the first...
-
One end of a wire is attached to a ceiling, and a solid brass ball is tied to the lower end. The tension in the wire is 71.2 N. What is the radius of the brass ball?
-
On November 1, Carver Equipment had a beginning balance in the Office Supplies account of $400. During the month, Carver purchased $900 of office supplies. At November 30, Carver Equipment had $300...
-
A 2 kg ball moving at 4 m/s collides with a stationary 1 kg ball. What is the speed of the 1 kg ball after the collision if the collision is: (a) elastic, and the speed of the 2 kg ball drops to 1...
-
ABC Manufacturing Inc. Income Statement Year Ended December 31, 20X4 Sale $ 200,000 Cost of goods sold $ 120,000 Gross Profit $ 80,000 Operating Expenses $ 40,000 Loss on Sale of equipment $ 2,000 $...
-
consider the following information for bonds: A or above 0.2% 0.05 Raling Average default rale Average beta BBB 0.5% 0.1 BB 2.3% 0.18 B 6.0% 0.25 CCC 12.2% 0.30 1. A BB hond has a yield to maturity...
-
You are a Loan Officer with an Investment Bank. Today you need to set your lending parameters. They are: LTV: 55% 10 Year T-Bill: TBD Rate Markup: 300 Basis Points Term: 30 Years Amortization: 30...
-
Listing 2.7, ShowCurrentTime.java, displays the current time. Revise this example to display the current date and time. The calendar example in Listing 6.12, PrintCalendar.java, should give you some...
-
Write two programs to display the available locales and time zone IDs using buttons, as shown in Figure 36.16. Exercise36_04 America/Phoenix Armerica /Port-au-Prince America/Port_of_Spain...
-
The book uses LinkedList for buckets. Replace LinkedList with AVLTree. Assume E is Comparable. Redefine MyHashSet as follows: public class MyHashSet> implements Collection { ... } Test your program...
-
United Technologies Corporation (UTC), based in Hartford, Connecticut, owns a wide variety of companies that operate in different businesses and industries. Some of the companies in UTCs portfolio...
-
How does the auditors professional duty of confidence affect disclosures to third parties?
-
When can auditors disclose unlawful acts to the police?
Study smarter with the SolutionInn App