Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using int main(int argc, char*, argv[]) Thank you in advance for the help. This program requires the utilization of concepts in Chapter 4, 5 and

Using int main(int argc, char*, argv[])

Thank you in advance for the help.

This program requires the utilization of concepts in Chapter 4, 5 and 6. Information regarding the test scores for a class is stored in an input file. The test scores and some supporting information is read from the input file. This information is then processed and written to an output file (see the sample output shown above). Using command line arguments for an input file and output file name (see command line argument slides and page 3), print out the command line input file name (see the sample solution for the output to use) and open the input file provided. Verify that the file opened successfully (file stream is valid). If it did not open successfully, enter a while loop that outputs an error message, resets the input file stream being opened and prompts the user to enter another input file name. This file name is read, echo printed and opened. The loop continues until the input file is successfully opened. See project 5 for the error message information the while loop is the exact same (without the return 1;) just replace if with while. If the input file is successfully opened, print out the command line output file name and open the output file provided. Verify that the output file opened successfully. If it did not open successfully, enter a while loop that outputs an error message, resets the output file stream being opened and prompts the user to enter another output file name. This file name is read, echo printed and opened. The loop continues until the output file is successfully opened. Use the filename Bad/file to cause the open function to fail for the output file. The input file contains three lines. The first line is a header line containing the name of the person submitting the grades. The second line consists of 4 integer grades separated by white space. The last line is an information line that is to be used when writing to the output file. This information line is a phrase similar to Test scores for section 01:. See the sample input files for further information. When reading the data from the file, the first line is ignored (no information is required from it). Then the four scores are read and stored in integer variables. After reading the scores, the status of the input stream is tested to verify that it is still valid. If the input stream is in the fail state mode, an appropriate error message is printed to the terminal AND the output file, and the program is terminated. If the input stream is valid, the scores are tested to ensure that they have positive values. If any score is less than 0, then the program prints out a message and the scores read to the terminal AND to the output file. The program is then terminated. If all scores read are greater than or equal to 0 and the input stream is still valid, the scores read are analyzed to determine their sum, average, letter grade for the average, variance and standard deviation. Formulas for performing these math functions are shown on the next page. The cmath header file may be needed for some of the math functions in the formulas. The letter grade for the average is based on the following scale for the average: Average >= 90 >= 80 >= 70 >= 60 < 60 Letter Grade A B C D F Lastly, the information line is read and used in the output as shown by the sample solution. After reading the information line, the input stream is tested to verify that it is still valid. If the input stream is in the fail state mode, then an appropriate error message is printed to the terminal AND the output file. The program is then terminated. The output is to be written to the output file as shown in the sample output on page 1. The top row has 17 asterisks and three spaces on either side of the word Statistics. Line 2 has the information line read from the input file. The last row consists of 50 asterisks. The solution uses setw(32) for establishing the fields in which the descriptions are written left justified. Output of all floating-point numbers is 2 decimal places. The test scores are read into integer variables and all calculated values are floating-point values.

Output would look something like this...

***************** Statistics ***************** Test scores for section 02: 85 76 83 69 The sum of the scores is: 313.00 The average of the scores is: 78.25 Letter grade equivalent: C The variance of the scores is: 52.92 The standard deviation is: 7.27 **************************************************

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago