Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 5 Description For this project, you will write a complete Ctt program that performs all of the following tasks Use variables of Data Type

image text in transcribed

image text in transcribed

image text in transcribed

Project 5 Description For this project, you will write a complete Ctt program that performs all of the following tasks Use variables of Data Type float to contain all numerical val command line arguments are used, first action of the program is to test to make sure that 2 file names were provided. Use the test if (argc 3). If the argc value is not 3, print out an error message and what the correct format should be for running the program and the program. (see page 4) terminate (2) Using command line arguments for an input file and output file name (see command line argument slides and page 3), open the input file provided as the first command line argument erify that the file opened successfully. If it did not open successfully, output an error mes nd terminate the program. See page 4 for information on this test. ) If the input file is successfully opened, open the output file provided as the second command line argument. Verify that the output file opened successfully. If it did not open successfully output an error message and terminate. Use the filename Bad/file" to cause the open function to fail for the output file (4) For steps 1 and 2 output a statement stating the name of the file being opened-see the solution ) The upper case letters A, B and C appear on the first, second and third line of the input file res pectively. The input file contains a single occurrence of these letters. Immediately after each letter is a floating point number which must be read, and there may or may not be more characters after the numbers on each line (6) Read in the three numbers and then test to see if any of them are less than 0. If any are negative, determine which ones are negative, output a message as shown in the sample solution and terminate the program. (7) If all numbers are greater than or equal to o, add them up and determine their average. From the average determine if the average is High (average > 75), Medium (average The program is to have error messages for the following conditions. Each of these tests results in termination of the program: Two file open error message: one for the input file and one for the output file o 15 s on either side of the heading and 47 t's across the bottom - rest of message comes from looking at sample solution output . Error output block for when one or more numbers are negative. 15 "s on either side of the heading and 47 s across the bottom. Rest of message comes from looking at the sample solution Run the sample solution to see the various error messages. See page 4 for more details. Project 5 Command Line Argumentse Be sure to look at the command line argument slides For this program, instead of int main) use: int main(int argc, char *argv 1) To run your program, type the following at the command line: .Project 05 input file name output file name In your program, assign argvi1] to a string variable (ie. inFileName argv[1]) that is to hold the input file name and argvI2] to a string variable(ie. 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 ine arguments. s Testing the State of the File Stream> 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.faill0) cout Input file failed to open properly!!Nn" cout Attempted to open fille: "Terminating program!!!n" 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 argv[O] is Project 05, the second value counted and stored in argv[1] 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(arge != 3) 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_2

Step: 3

blur-text-image_3

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

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

3. Identify cultural universals in nonverbal communication.

Answered: 1 week ago