Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ program to write the grades on a file the names of the files are shown in the picture here is my complete question Input

image text in transcribed c++ program to write the grades on a file the names of the files are shown in the picture

here is my complete question image text in transcribed
image text in transcribed
Input rawgrades-bw101.csv Your output Your program produced no output Name Scores (Low) Total Average Grade Fred Flintstone Barney Rubble Yogi Bear Secret Squirre.l Dick Dastardly 70 82 55 80 55) 65 62 0 71 0) 89 92 100 95 89) 75 7783 81 75) 59 0 37 0 0) 232 198 287 241 96 77.33 66.00 95.67A 80.33 32.00 Expected output 10: Star Wars-Report 0/5 Could not find file: grade-report-starwars.txt Input rawgrades-starwars.csv Your output Your program produced no output Name Scores (Low) Total Av erage Grade 272 282 239 90.67 94.00 79.67 300 100.00 300 100.00 83.67 Luke Skywalker Leia Organa Han Solo 88 97 87 84 84) 94 100 88 83 83) 87 69 18 83 18) 100 100 100 99 99) 100 100 99 100 99) 95 2789 67(27) 98 93 96 97 93) 37 50 3 0 0) Expected output Threepio Artoo Darth Vader Ben Kenobi Jar-Jar Binks 251 291 90 97.00A 30.00 Starter Code nput File Format Output File Format Output File Format aerage and 515 5 2 31 66.0 mplementing the helper functions The Top-Level Functions bool openFiles(..) This function opens the input and output files, associating the files with the provided input/output file streams If the input file fails to open, the following message should be output before the function retuns false Pailed to open for reads Cname-of-input-file> If the output file fails to open, the following message should be output before the function returns false Failed to open for wri te: The function should return true only if both files opened successfully. Returning false signals to the main program that some error occurred and that the run should be aborted This function has been implemented for you. It writes the report header (invoking a function also written for you), then loops over the lines read in from the input file, invoking processLine( ) for each one Helper Functions To break the problem down into manageable pieces, helper functions have been defined to solve small, specific tasks. These will need to be implemented correctly, and called from the appropriate places to complete the prect. Youl find them in the starter code, but as a quick summary // Returns true if fname is of the fornrawgrades-className>.esr" bool validInputFilename (const stzing &Ename) / Parses a record (line), placing the substrings into name, id, scores, and sl...4 void parseStudentRecord (const string Gline,atring Gname, atring id, int sl, int &s2, int &s3, int &s4) // Returns the smaller of the two values int min (int a, int b) // Returns the snallest of all the values int nin(int a, int b, int e, int d) // Returns a letter grade for the given score char gradeFromScore (double score) // Processes a line read from the raw-grades input file void processLine (ostream ut, const atring &line) /Writes the report header to the given output file stream (ALREADY DONE) void writeReportHeader (ofstrean Gout Some notes on parseStudentRecord Given a line of text, stored in the variable line, you must extract the substrings that are separated by commas. There are a couple of approaches you can take for this o Method 1 . Load the line into a stringstream . Use the overload of getline that takes an optional delimiter. This causes getline to read up to a comma instead of a newline o Method 2 . Use use.find to find commas, then use substr to extract substrings from in between those commas Once you have extracted the scores as strings, you will have to convert them to ints For this you can use either stoi (string to int) or a tring tream Input rawgrades-bw101.csv Your output Your program produced no output Name Scores (Low) Total Average Grade Fred Flintstone Barney Rubble Yogi Bear Secret Squirre.l Dick Dastardly 70 82 55 80 55) 65 62 0 71 0) 89 92 100 95 89) 75 7783 81 75) 59 0 37 0 0) 232 198 287 241 96 77.33 66.00 95.67A 80.33 32.00 Expected output 10: Star Wars-Report 0/5 Could not find file: grade-report-starwars.txt Input rawgrades-starwars.csv Your output Your program produced no output Name Scores (Low) Total Av erage Grade 272 282 239 90.67 94.00 79.67 300 100.00 300 100.00 83.67 Luke Skywalker Leia Organa Han Solo 88 97 87 84 84) 94 100 88 83 83) 87 69 18 83 18) 100 100 100 99 99) 100 100 99 100 99) 95 2789 67(27) 98 93 96 97 93) 37 50 3 0 0) Expected output Threepio Artoo Darth Vader Ben Kenobi Jar-Jar Binks 251 291 90 97.00A 30.00 Starter Code nput File Format Output File Format Output File Format aerage and 515 5 2 31 66.0 mplementing the helper functions The Top-Level Functions bool openFiles(..) This function opens the input and output files, associating the files with the provided input/output file streams If the input file fails to open, the following message should be output before the function retuns false Pailed to open for reads Cname-of-input-file> If the output file fails to open, the following message should be output before the function returns false Failed to open for wri te: The function should return true only if both files opened successfully. Returning false signals to the main program that some error occurred and that the run should be aborted This function has been implemented for you. It writes the report header (invoking a function also written for you), then loops over the lines read in from the input file, invoking processLine( ) for each one Helper Functions To break the problem down into manageable pieces, helper functions have been defined to solve small, specific tasks. These will need to be implemented correctly, and called from the appropriate places to complete the prect. Youl find them in the starter code, but as a quick summary // Returns true if fname is of the fornrawgrades-className>.esr" bool validInputFilename (const stzing &Ename) / Parses a record (line), placing the substrings into name, id, scores, and sl...4 void parseStudentRecord (const string Gline,atring Gname, atring id, int sl, int &s2, int &s3, int &s4) // Returns the smaller of the two values int min (int a, int b) // Returns the snallest of all the values int nin(int a, int b, int e, int d) // Returns a letter grade for the given score char gradeFromScore (double score) // Processes a line read from the raw-grades input file void processLine (ostream ut, const atring &line) /Writes the report header to the given output file stream (ALREADY DONE) void writeReportHeader (ofstrean Gout Some notes on parseStudentRecord Given a line of text, stored in the variable line, you must extract the substrings that are separated by commas. There are a couple of approaches you can take for this o Method 1 . Load the line into a stringstream . Use the overload of getline that takes an optional delimiter. This causes getline to read up to a comma instead of a newline o Method 2 . Use use.find to find commas, then use substr to extract substrings from in between those commas Once you have extracted the scores as strings, you will have to convert them to ints For this you can use either stoi (string to int) or a tring tream

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions