Question: Comparison Script Path lhome/worklcpe211datalProject 06/CompareSolution.bash Project 06.cpp For a valid input file, the information written to the output file loos like the following: AAWEStatisticsIan Test

 Comparison Script Path lhome/worklcpe211datalProject 06/CompareSolution.bash Project 06.cpp For a valid input

file, the information written to the output file loos like the following:

AAWEStatisticsIan Test scores for section 02:85 7683 69 The sum of the

scores is: The average of the scores is: 78.25 Letter grade equivalent:

Comparison Script Path lhome/worklcpe211datalProject 06/CompareSolution.bash Project 06.cpp For a valid input file, the information written to the output file loos like the following: AAWEStatisticsIan Test scores for section 02:85 7683 69 The sum of the scores is: The average of the scores is: 78.25 Letter grade equivalent: The variance of the scores is: 52.92 The standard deviation is: 313.00 7.27 Project 6 Restrictions Only material from Chapters 1 through 7 and any extra code in this handout is allawed You cannot use any Citechniques that are covered in Chapters 8 and higher No giobal vanables and No arrays are allowed You are not allowed to use any global variables ine in a program. All variables should be declared in maino es. Global variables are declared above the int main0 Project 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 witten 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 per line is an infomation line that is to be used when writing to the output file. This information line is a phrase submitting the grades. The second line consists of 4 integer grades separated by white space. The last 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 stream is tested to verify that it is still valid. If the input stream is in the fail state mode, an appropnate If the input stream is valid, the scores are tested to ensure that they have positive values. If any score is four scores are read and stored in integer variables. After reading the scores, the status of the input is printed to the terminal AND the output file, and the program is terminated 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 average, variance and standard analyzed to determine their sum, average, letter grade for the 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 fomulas. The letter grade for the s based on the following scale for the average: r Grade 90 >= 80 c 60 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 verity 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. Input is to follow the same order as that illustrated by the provided solution executable. Output is to match that shown by the provided solution executable. Project 6 C++ Concepts Explained The following C++ concepts are included or introduced in this project The cmath header file: This header file contains definitions for various math functions inctuding the pow(x.y) function. The pow(x,y) function calculates the value of x. If powx.y) is used when calculating the variance, y must be the integer value of 2 Formulas Required Average Xsum 72 variance var 2x-Xavg) 1 Standard Deviation war There are two ways to terminate a program in main before it reaches the retum O; at the end of main One method requires placing a return 1; (number can be anything but 1 is typically used) statement at the point where the program is to be terminated. The other method is to use the exit (1); statement. If the exit(1) statement is used, all output files must be kclosed before executing the exit(1) statement Closing the output file will empty its bufter before the program terminates. To use the exit function, the closed before executing the exit(1) statement header file cstdlib must be used. Project 6 Hints Test the operation of your program using the sample data files provided. Compare results from your program to those of the sample solution. You may need to create your own fles to test all possible conditions Several header files are required: string, iomanip, fstream, cmath and cstdlib. To terminate a program at a specific point, put in the statement retum 1: If you use exit (), nstead of return 1i you will have to close your output file before executing the exit statement and use the header file cstdlib. . When te st scores are output, they are left justfed in a field wicth of 6 (use with all 4 scores ) Be sure to test your program with all of the input files supplied and invalid input'output file names .Run the companison script once you believe your program is working correcty . The row of asterisks on all the error messages consist of 47 asterisks . The bottom n row of asterisks on the statistics output contains 50 asterisks. To print out 50 asterisks, you can use string(50,') It de sired, you can modity the makefie from project 5 for use with this project. the top line Output for all floating point values is to be 2 decimal places . . File Open and File Read Error messages have 47 "s across the bottom and 15 "s on the Project 6 Command Line Arquments> 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 folloing at the command line: ]) iProject o6 input file name output file name In your program, assign argv[] to a string vanable (inFileName-argv[1]:) that is to hold the input le name and argv2] to a string variable(outFileNameFargv[2) that is to hold the output file name. Use these string variables in the open tunction when opening the files. When running the sample solution (not the comparison script), you must provide the input and output fle names as command line arguments

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!