This is the assignment.
Purpose:
The purpose of this assignment is for you to demonstrate your ability to design and code a program that employs a multi-decision construct such as else...if, or switch to resolve a problem that has a multiplicity of conditions to be evaluated. Use the else...if for question 1; switch for question 2.
Specifications:
Professor C. N. Fusing administered an exam in which there were only two questions. The questions were multiple-choice with five options each. To test the students reasoning, none of the answers were incorrect but were intended to determine a student’s depth of understanding of the material. Each answer had a different point value with 10 as the maximum and 5 the minimum. They were weighed as follows:
Question 1 – A = 5, B = 7, C = 10, D = 5, E = 8;
Question 2 – A = 10, B = 5, C = 8, D = 7, E = 5.
Should a student fail to answer a question, the professor will enter an F to indicate such. An F answer gets a score of zero (0). To avoid the problem of upper and lower case, use the toupper function to convert the input character. If the answer entered for any question is not between A and F, display an error message, and then end the program.
The professor needs a program to help him calculate the total score and letter grade for a student. The letter grade is to be assigned as follows:
18 – 20 = A; 16 – 17 = B; 14 – 15 = C; 10 – 13 = D; 0 – 9 = F
Design, code, compile and execute a program to supply the professor with the results he needs. Display the student’s first and last name, the answers to the questions, total score, and letter grade for the student’s pair of answers.
I've worked on this for several days now and have redone several codes but I still can not get it. Can some assist me in helping me correct my mistakes?
Code:#include <iostream> using namespace std; int main () { string firstname, lastname; char ans1, ans2; int score; char A,B,C,D,E,F; cout << "Enter student's first and last name:" <<endl; cin >> firstname >> lastname; cout << "Enter answer to question 1:"; cin >> ans1; if (ans1== A){ A =5; } else if (ans1== B){ B = 7; } else if (ans1 == C){ C = 10; } else if (ans1 == D){ D = 5; } else if (ans1 == E){ E = 8; } else if (ans1 ==F){ F==0; } else cout << "\nInvalid!!" <<endl; cout << "Enter answer for question 1:"; cin >> ans1; cout << "Enter answer to question 2:"; cin >> ans2; switch (ans2){ case 1: A = 10; break; case 2: B = 5; break; case 3: C = 8; break; case 4: D = 7; break; case 5: E = 0; break; case 6: F = 0; break; default: cout << "Invalid!!"<<endl; } cout << "Enter answer for question 2:"; cin >> ans2; cout << "Student's name:" <<endl; cin >> firstname >> lastname; cout << "Answers:"; cin >> ans1 >> ans2; cout << "Score:"; score=ans1+ans2; cout <<score<<endl; cout << "Grade"; cin >> score; if (score >= 18-20 ) cout << "Your grade is an A" << endl; else if (score >= 16-17 ) cout << "Your grade is a B" << endl; else if (score >= 14-15 ) cout << "Your grade is a C" << endl; else if (score >= 10-13) cout << "Your grade is a D" << endl; else cout << "Your grade is an F"; system ("pause"); return EXIT_SUCCESS; }