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...
-
A ball rolling along a floor doesn't continue rolling indefinitely. Is this because it is seeking a place of rest or because some force is acting upon it? If the latter, identify the force.
-
In 2016, Alliant Corporation acquired Centerpoint, Inc. for $300 million, of which $50 million was allocated to goodwill . At the end of 2018, management has provided the following information for a...
-
How does solid enter into washing calculations? Where does solids flow rate implicitly appear in Figure 14-1? Feed U, xo A Mixer Settler B Underflow Stage I Overflow 0112 Stage 2 U | 2 N-1 N Uo,xo xj...
-
Picasso Company is a wholesale distributor of professional equipment and supplies. The companys sales have averaged about $900,000 annually for the 3-year period 20122014. The firms total assets at...
-
Sienna's Shades produces standard and deluxe sunglasses: (Click the icon to view the information.) The company has 16,000 machine hours available. In one machine hour, Sienna's can produce 40 pairs...
-
1. a. How much did the materials cost per unit change between June and July? b. How much did the conversion cost per unit change between June and July? 2. Which is the optimal choice of material and...
-
What are the two factors the competition Bureau will consider when determining if the mere refusal of IP licensing has adversely affected competition to a degree that would be considered substantial...
-
The City of Leonard decides to lease school desks for its school system rather than buy them because the lessor will do all scheduled maintenance. On January 1 , 2 0 2 4 , the school system leases 5...
-
Completion Complete each statement. 1. ____________________ is used when you want to shut down a cluster server for maintenance or upgrades, such as adding memory or replacing a failing component....
-
Morton Company s budgeted variable manufacturing overhead is $ 4 . 5 0 per direct labor - hour and its budgeted fixed manufacturing overhead is $ 2 7 0 , 0 0 0 per year. The company manufactures a...
-
Identify the correctly punctuated sentence below. Question 1 Selected answer will be automatically saved. For keyboard navigation, press up/down arrow keys to select an answer. a Your presentation...
-
Consider the real-time transport of audio across a network. (a) What are the advantages of digitising the audio? (b) What are the disadvantages and how can they be mitigated? (c) What...
-
Assume you can earn 8.6% per year on your investments. a. If you invest $180,000 for retirement at age 30, how much will you have 35 years later for retirement? b. If you wait until age 40 to invest...
-
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...
-
The following selected balance sheet and income statement data were taken from the financial records of The Ventura Company: Required 1. Use the Dupont Model to compute the 2013 through 2016 return...
-
North Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During 2019, North sold land for \(\$ 70,000\) cash that had originally cost \(\$ 45,000\)....
-
The Pruitt Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During the year, the company sold for \(\$ 15,000\) cash old equipment that had cost...
Study smarter with the SolutionInn App