Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For his projeet, you will wrto a comploto C program that portoma aW of the following tasks Use variables of Data Type oat to contain
For his projeet, you will wrto a comploto C program that portoma aW of the following tasks Use variables of Data Type oat to contain all numerical values 1) Because command ine arguments are used, first sction of the program is to teet to make sure that 2 file names were provided Use the test if ag3) If the argc value is not 3, print out an error message and what the corect format should be for running the program and teminale (21 Using command ine arguments for an input tle and output le name (see command ine argument sides and page 3l, open the inpu epovided as the first command line argument. Venity that the file opened suocesstulty. If tdid not open successfully, output an emor message and berminate the program.-See page 4 for information on this test (31 "the input tle is suocesstuly openedopen the output tle provided aste scoord Domrmand Iine argument Verify that the output fie opened successfuly. I it did not open sucoessuly output an emor message and terminate. Use the filename Bad/file to cause the open function to fail for the output la 4) For steps 1 and 2 output a stalement stating the name of the ile being opened-see the solution 51 The uppor case letters A, B and C appear on the first, second and third ine ot the input ile raspectivaly. The input file costains a single cccurrance of hese latters. Immediately ater each letter is a loating point umber which must be read, and there may or may not be none characlers after the rumbers en each line 8) Read in the free numbers and then test to see if any of them are less than 0. H any are negative, determine which ones are negative, output a message as shown in the sample alioon and ermnate the program (7 If all numbers are greater than or equal to 0, add them up and determine their average. From the average delermre if the a erage is Hgh (average >-75), Modum lave age aerage-25) or Low laverage 25) 75 and (B) Wite the numbars road, their sum, thai r average and the word High, Madium or Low based on the average to the ourput file-un the sample solution to ase the fomatting necessary for the ouput The row of s is 47 s long and the phrases are in a field width of 35 (9) Cutput of the program shall match that of the sample solution . When al numbers are positve make sure output is to the oput file- including the ounput statememts that set up the fomatting Al crror messages are writen to the terminal. .For a program written expecting command line arguments, a segmertation tsult wil occur it command line arguments are not provided Aun the sample solution (not the comparison script) to see what the program writes to the terminal and to the output tle, and the oeder in which the inormation is written. .Look at the contents of an irput tle (see page 3) to see what has to be read Page 2 of 4 Spring 2019 CPE211 Praject Aasignment Project 5 The hput flo fomat ia simlar to the information shown balow. Lock at all o the provided input les to determine the xact format. Note use the ignore tunction to move the reading marker to the first charactar atter the A, B or C Use the extracion operator to read in the values line 1 has A-65.98 the Eirat nunber B14.23 i the second number the third number is C88.88 sProject 5 Error Messagese The program is to have error messages for the following conditions. Each of these tests results in Two sle open emor messape: one for the irput fie and cne for the output sie o 15 s on ether side al the heading and 47 s across the botlom- rest of message comes from looking at sample soluton output Emor outpu block for when one or more numbers ane negative. 15s on ether sido of the heading and 47 "8 cross the bomom Rest of message comes from looking at he sample Run the sample solubon to see the various emor messages. Sce page 4 for more details. Be sure to lock at the command line argument sides For tis program, instead of int mtar10 use ant na inint 8rgc, char * argv[ ] } To run your program, type the folowing at the command line: hat In your program, assigno a string vaable (i inFileName-agv1 that is 1o hold the ingut file name and argv[2] to a stting variable(Le, outFileName = argv[21'"en is to hold the outpst file name. Use these string variables in the open functon when opening the fies oupt re niame. Uego When nunning the sample solution Inot the comparison scripth you must provide the inpun and outpst ile names as command ine arguments Page 3 of4 Sprirg 2019 CPE211 Project Assignment Project 5 -75), Modum lave age aerage-25) or Low laverage 25) 75 and (B) Wite the numbars road, their sum, thai r average and the word High, Madium or Low based on the average to the ourput file-un the sample solution to ase the fomatting necessary for the ouput The row of s is 47 s long and the phrases are in a field width of 35 (9) Cutput of the program shall match that of the sample solution . When al numbers are positve make sure output is to the oput file- including the ounput statememts that set up the fomatting Al crror messages are writen to the terminal. .For a program written expecting command line arguments, a segmertation tsult wil occur it command line arguments are not provided Aun the sample solution (not the comparison script) to see what the program writes to the terminal and to the output tle, and the oeder in which the inormation is written. .Look at the contents of an irput tle (see page 3) to see what has to be read Page 2 of 4 Spring 2019 CPE211 Praject Aasignment Project 5 The hput flo fomat ia simlar to the information shown balow. Lock at all o the provided input les to determine the xact format. Note use the ignore tunction to move the reading marker to the first charactar atter the A, B or C Use the extracion operator to read in the values line 1 has A-65.98 the Eirat nunber B14.23 i the second number the third number is C88.88 sProject 5 Error Messagese The program is to have error messages for the following conditions. Each of these tests results in Two sle open emor messape: one for the irput fie and cne for the output sie o 15 s on ether side al the heading and 47 s across the botlom- rest of message comes from looking at sample soluton output Emor outpu block for when one or more numbers ane negative. 15s on ether sido of the heading and 47 "8 cross the bomom Rest of message comes from looking at he sample Run the sample solubon to see the various emor messages. Sce page 4 for more details. Be sure to lock at the command line argument sides For tis program, instead of int mtar10 use ant na inint 8rgc, char * argv[ ] } To run your program, type the folowing at the command line: hat In your program, assigno a string vaable (i inFileName-agv1 that is 1o hold the ingut file name and argv[2] to a stting variable(Le, outFileName = argv[21'"en is to hold the outpst file name. Use these string variables in the open functon when opening the fies oupt re niame. Uego When nunning the sample solution Inot the comparison scripth you must provide the inpun and outpst ile names as command ine arguments Page 3 of4 Sprirg 2019 CPE211 Project Assignment Project 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started