Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Project_05 error message info: The output: Proiect 6 Description This program requires the utilization of concepts in Chapter 4, 5 and 6. Information regarding

C++

image text in transcribed

image text in transcribed

image text in transcribed

Project_05 error message info:

image text in transcribed

The output:

image text in transcribed

Proiect 6 Description 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). i 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 Be sure to look at the command line argument slides For this program, instead of int main use: int main(int argc, char *argv[ ]) To run your program, type the following at the command line /Project 06 input file_name output file_name In your program, assign argv[1] to a string variable (inFileName-argv[1]:) that is to hold the input file name and argv[2] to a string variable(outFileName argv[2]) that is to hold the output file name. Use these string variables in the open function when opening the files When running the sample solution (not the comparison script), you must provide the input and output file names as command line arguments Be sure to test for the correct number of command line arguments in your program see project 5 A makefile has been provided that you can use to compile your program. For information on makefiles, look at the makefile slides and look at material in Project 04 The following code is used to test the status of a file stream. Replace the file stream variable indicated (your file stream) with the actual name of the file stream used in your program. Also, replace the file name string variable (filename) with the actual name of the variable that holds the name of the file entered by the user if (your file stream.fail)) cout Input file failed to open properly 11 "; cout Attempted to open file: .. Terminating program 111 "; cout The following code is used to test the number of arguments provided on the command line. When running project 5, the following command is used: /Project 05 inputFileName outputFileName The first value counted and stored in argvI0 is /Project 05, the second value counted and stored in argv1] is inputFileName and the third value counted and stored in argv[2] is outputFileName So for this project, there are 3 arguments and argc should have the value of 3. Code for your program is the following if (argc 3) cout Incorrect number of Command Line Arguments "; cout Command for cout . /Project-05 inputFileName outputFileName "; cout

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions