Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C++ to grade an n-question multiple-choice exam (n CS 121-02 Program 2 Due: 2/25/2020 Spring 2020 Value: 100 Problem Description: Write

Write a program in C++ to grade an n-question multiple-choice exam (n

image text in transcribed

image text in transcribed

CS 121-02 Program 2 Due: 2/25/2020 Spring 2020 Value: 100 Problem Description: Write a program to grade an n-question multiple-choice exam (n =10) and produce a report. Your program will read the data from a file called testdat.txt, containing the answer key and individual student responses. It will produce an output file called examrep.txt that contains the answer key, the individual scores of each student, expressed as a percentage and the average score. Input: The first line of the file consists of the number of questions on the exam, followed by a space and then an n-character string of the correct answers. The remaining lines in the file consist of the individual answers. Each line contains an integer student ID followed by a space and the student's answers. For example: 10 aabbcdcdab 101 aadbcdcaab 212 aabbcdcaab 312 babbodabod 222 aabbcdcdab Use an end-of-file loop to read the file. Count the number of students who took the test by incrementing a counter numst each time a new ID/grade string pair is read. Output: The output file should look something like this: Grade Report and Analysis Question Answer 1 2 3 4 5 6 7 0.00 10 Student ID Score (%) 101 80 212 90 312 50 222 100 Answers aadbcdca ab aabbcdcaab babbcdabcd aabbcdcdab Your output doesn't have to look exactly like this - you can add features or reformat, but keep it neat. Variables and Constants 1. Define named constants to represent the maximum number of questions. 2. When the answer key is read, store the answers in a string variable. 3. Declare an array to hold the student test grades 4. Also declare a string variable to hold a student's answers while you read and process them. 5. There's no need to store student IDs or answers permanently, only student grade. Processing String Variables You can access the individual characters in a string variable by using indexes, just like arrays. Let's assume we have defined a character variable letter and a string variable word and that we've initialized word to "elephant". We can use a function from the string library: letter word.at (0) to store the first letten. 2. We can index the string variable directly: letter word[0]. or Here's an outline of the code needed to match a student's answers to the answer key: for (i=0; i

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

State three commonly used research methods in behavioral science.

Answered: 1 week ago