You have been asked to write a program to grade several multiple-choice exams. The
exam has 20 questions, each answered with a letter in the range of ‘a’ through ‘f’. The
answers key is declared in the program as constant of type string. An example of answer
key is “abcdefabcdefabcdefab”. Your program should work for any other answer key.
The program should first ask users for the number of students to be graded. Then it
should have a while loop in the main function. For each student, the loop repeatedly asks
users to enter a student ID number and a string of characters representing the answers of
the student. The student ID number is of type string and should contain exactly 7 digits
(each digit between ‘0’ and’9’). If a student ID number is incorrect, the program displays
and error message and prompts the user to re-enter that student information. If a student
gives more answers than necessary (more than 20 in our case), the program automatically
truncates the extra answers. On the other hand, if a student provides less number of
answers, the remaining unanswered questions are considered as being answered wrongly.
If for a given answer, the user enters a letter other than ‘a’, b’, ‘c’, ‘d’, ‘e’, or ‘f’ then the
question is considered as being wrongly answered.
Furthermore, in each while loop in the main routine, your program should compute a
percentile score for the student by comparing the answers for that student to the answers
key, and a curved grade in ‘A’ though ‘F’ based on the following:
>=90
A
<90 and >=80
B
<80 and >= 70
C
<70 and >= 60
D
<60 and >= 50
E
<50
F
The results of each student are displayed by the student in the format: percentile score
and a curved grade in ‘A’ though ‘F’.
The program should also compute and display the following statistics for the graded
answers: Average score, Maximum score, and Minimum score.
Use the following inputs to test your program:
Answer key = abcdefabcdefabcdefab
abbcdaefcdffbceffadbc
Please enter the number of students to be graded: 5
For each of the following students, enter the Student ID and answers:
Student 1: 1234567 abcdefabcdefabcdefab
Score: 100% A
Student 2: 9876543 abddefbbbdefcbcdefac
Score: 75% C
Student 3: 555444656 abcdefabcdefabcd
ERROR in the Student ID number. Please re-enter Student 3 information:
Student 3: 5554446 abcdefabcdefabcd
Score: 80% B
Student 4: 4445556 abcdefabcdefabcdefabcdaedf
Score: 100% A
Student 5: 5551112 abbcdaefcdffbceffadbc
Score: 30% F
Statistics:
Average Score: 75%
Minimum Score: 100%
Maximum Score: 30%
The score of student 5 is 30% (6/20). Student 5 gives 21 answers, compared to 20
answers in the key. We discard any extra answers, which are more than 20.
To provide solutions to this project, you need to deliver the following components on the
basis of principles in software engineering.
// C++ program to calculate the grades for students for multiple choice exam
#include <iostream>
#include <cctype>
using namespace std;
// function declaration
bool isStudentIdValid(string studID);
int main() {
string answer = "abcdefabcdefabcdefab"; // correct answers
int numStudents;
int totalScore = 0,minScore = answer.length(),maxScore = 0;
int score;
string studId, stud_ans;
// input for number of students
cout<<" Please enter the number of students to be graded: ";
cin>>numStudents;
cout<<" For each of the following students, enter the Student ID and answers: "<<endl;
int i=1;
// loop to input student data and calculate its grade
while(i <= numStudents)
{
cout<<" Student "<<i<<" : ";
cin>>studId>>stud_ans;
// validate the student id
while(!isStudentIdValid(studId))
{
cout<<" ERROR in the Student ID number. Please re-enter Student "<<i<<" information: "<<endl;
cout<<" Student "<<i<<" : ";
cin>>studId>>stud_ans;
}
score = 0;
// calculate the score
if(stud_ans.length() < answer.length())
{
for(int j=0;j<stud_ans.length();j++)
{
if(tolower(stud_ans.at(j)) == tolower(answer.at(j)))
score++;
}
}else{
for(int j=0;j<answer.length();j++)
{
if(tolower(stud_ans.at(j)) == tolower(answer.at(j)))
score++;
}
}
// update maxScore and minScore
if(maxScore < score)
maxScore = score;
if(minScore > score)
minScore = score;
int score_percent = ((score*100)/answer.length());
totalScore += score;// add to totalScore
cout<<" Score : "<<score_percent<<"% ";
if(score_percent >= 90)
cout<<"A"<<endl;
else if(score_percent >=80)
cout<<"B"<<endl;
else if(score_percent >=70)
cout<<"C"<<endl;
else if(score_percent >=60)
cout<<"D"<<endl;
else if(score_percent >=50)
cout<<"E"<<endl;
else
cout<<"F"<<endl;
i++;
}
cout<<" Statistics : "<<endl;
cout<<" Average Score: "<<(totalScore*100)/(answer.length()*numStudents)<<"%"<<endl;
cout<<" Minimum Score: "<<(minScore*100)/(answer.length())<<"%"<<endl;
cout<<" Maximum Score: "<<(maxScore*100)/(answer.length())<<"%"<<endl;
return 0;
}
// function to determine if the student id is valid or not
bool isStudentIdValid(string studID)
{
if(studID.length() != 7)
return false;
for(int i=0;i<studID.length();i++)
if(studID.at(i) < '0' || studID.at(i) > '9')
return false;
return true;
}
//end of program
Output:
You have been asked to write a program to grade several multiple-choice exams. The exam has...
Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...
Write a Java program, including comments, to compute statistics for how students did on an exam. The program should compute various things about a student and print it all out. Then it repeats the process for each new student until the entire set of data has been completed. (a) The program reads in and prints the ID number of a student [see step (g) below] and then the number of right answers and the number of wrong answers. (The total...
C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade is determined by first calculating her weighted average as follows: (score1 + score2 + score3 + score4 + max_score) weighted_average = ----------------------------------------------------------------------- 5 This counts her maximum score twice as much as each of the other scores. Her letter grade is then a A if weighted average is at least 90, a B if weighted average is at least 80...
Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...
You will create a class to keep student's information: name, student ID, and grade. The program will have the following functionality: - The record is persistent, that is, the whole registry should be saved on file upon exiting the program, and after any major change. - The program should provide the option to create a new entry with a student's name, ID, and grade. - There should be an option to lookup a student from his student ID (this will...
Java: The local Driver's License Office has asked you to write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. B 6. A 11.B 16. C 2. D 7. B 12.C 17. C 3. A 8. A 13.D 18. B 4. A 9. C 14.A 19. D 5. C 10. D 15.D 20. A Your program should store the correct answers in an array. (Store each question's answer in an element of a String array.) The program...
codeblock c++ language Write a program that reads students test scores in the range 0-200 from a file until end of file (use e of() to check if ifstream reaches the End of File Stream) and store those scores in an array. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100- 124, 125–149, 150-174, and 175–200. Finally, the program outputs the total number of students, each score range...
in C porgraming . use #include〈stdio.h〉 #include〈stdlib.h〉 Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and scores are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 2011710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student_id,...
using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...
Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and calculate the average score over a number of tests for a number of students. The program should: 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the scores...