Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives: Use strings, files, and command line arguments. You are asked to grade a multiple choice test for a class. The students' answers are stored

image text in transcribed

Objectives: Use strings, files, and command line arguments. You are asked to grade a multiple choice test for a class. The students' answers are stored in a file. Each student record in the file includes a student name and the test answers given by the student. A blank space indicates that the student did not answer the question. For example, the following line represents a student's record. Sample output: Washington, George Answers, correct answer in parenthesis George Bush cCDdaab ccaADdo 1: a (a) 2: d(c) 3: d(d) 4:b(b) 5: c(c) 6: b(b) 7: d(d) 8: c(c) 9:-(c) 10: a(a) 11: c(c) 12: c(d) 13: a (a) 14: c(c) 15 c(c) In the above sample input, George Bush did not answer question 8 The test answer key is entered in the first line of the input file (ACDBCBDCCACDACC) Score : 80.0% B Write a C++ program that determines the scores and letter grade of students' multiple-choice tests. The number of test questions must be determined by reading the answer key string at the beginning of the input file. You may assume that there are no more than 100 questions and no more than 100 students. Output the following: Adams, John .A grade report for each student that is similar to the sample output below. Replace a Answers,correct answer in parenthesis missing answer with a-' The test average and letter grade. (Extra Credit): The names and averages of the students with the highest grades. No hints will be given for the extra credit. 1:(a) 2: c(c) 3: d (d) 4: b(b) 5:(c) 6: b (b) 7: d(d 8:(c) 9: c(c) 10: a (a) 11: c(c) 12:13: a (a 14:c(c)15:-(c) . Score : 66.7% D Your program must use command line arguments (see below) to get the input file name (exit the program with an error message if the file fails to open). The user may also enter the output file name as an argument if they wish to store the output in a file. Otherwise, the output should be displayed on the screen. The program can be run using one of the following commands: .. . Class average : 76.4% C Students with the highest grade (100%): Barack Obama Richard Nixon /a.out quiz.txt /a.out quiz.txt output.txt If your file name contains spaces surround the file name with double quotes as in: /a.out "input file name.txt" Sample input file ACDBCBDCCACDACC George Washington aDdbcBdc accAcc John Adams cdb bd cac ac Thomas Jefferson abcddaacbbcddda Ronald Regan bcdbcbDccACdacc John Kennedey cbbadcbbacdbadc Jimmy Carter abdcad abdcbacd George Bush CCDDAABBCCAADDC Barack Obama acdbcbdccacdacc Bill Clinton ACDBCBDCCACAACC Richard Nixon acdbcacccacdacc Required Functions: .Write a function that grades a single student score and returns the score. .Write a function that returns a letter grade for a score. . Write a function that outputs a single student's report to the screen. Parsing command line arguments In C++ you can input data (strings) into your program on the command line (command line arguments). You can capture these data by adding two parameters to your main program as follows: int main (int argc, char *argv) argc: (argument count) number of arguments on the line, including the name of the progranm argv: (argument vector) list of c-style strings that represent all the arguments including the name of the program (two dimensional array of characters) For example, executing the command ./a.out quizl.txt "output file.txt" Assigns: argc3 argv [0) will be"./a.out" argv [1) will be "quiz1.txt" argv [2) will be "output file.txt

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

More Books

Students also viewed these Databases questions