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 been working on this code for several days now. I've looked through my books and searched online for help, but I can not seem to comprehend what to do.

This is what I have so far.

I just need guidance in showing me what I'm doing wrong and comprehending what needs to be done so I can complete this assignemt. I deeply appreciate this help.

#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;


     switch(ans1)
    {
    case '1':
    A=5;
    break;
    case '2':
    B=7;
    break;
    case '3':
    C=10;
    break;
    case '4':
    D=5;
    break;
    case '5':
    E=8;
    break;
    default:
    F ==0;
    break;
    }
  
      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=5;
    break;
    default:
    F=0;
}
   
cout << "Student's name:" <<endl;
cin >> firstname >> lastname;
cout << "Answers:";
cin >> ans1 >> ans2;
cout << "Score:";
cin >> ans1+ans2=score;


 system ("pause");
 return 0;

}

I edited some things on my own, but now the two numbers aren't adding up correctly.

#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;
                                 }       
                               
  
      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;
  default:
    F = 0;
}


     
   
cout << "Student's name:" <<endl;
cin >> firstname >> lastname;
cout << "Answers:";
cin >> ans1 >> ans2;
cout << "Score:";
score=ans1+ans2;

cout <<score<<endl;


 system ("pause");
 return 0;

}

And this is my final correction. I still can't seem to get it right. Guidance would be greatly appreciated.

#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;

}

You have the understanding of variables incorrect ... looking at line 11 of your last post

char A,B,C,D,E,F;

This creates undelcared variables of A, B, C, D, E, and F. There is nothing in these variables. until you set them to something, they can't be used. You need to initilize them like so.

char A, B;
A = 'A';
B = 'B';
//etc

in line 21, the user will enter an a value for ans1. You will need to convert his input to an upper case letter (per instructions). This is done by using the toupper function.

ans1 = toupper(ans1);

I also think you need to #include <cctype>.

now that we have your ans1 in upper case, and your A,B,C,D,E,F variables initialized, you can start your comparisons.

In line 23,24,25 you have

if (ans1== A){
          A =5;
          }

What are you doing here? A is your 'A'. A is a character, not an integer. You need a score. A is a grade. A is not a number. What you are looking for here is

if (ans1== A){
          score = 5;
          }

In line 39, you have

F==0; // double equals, you need one and it should be score, not F.

And at the end of that if/else you have

else       
    cout << "\nInvalid!!" <<endl;
    cout << "Enter answer for question 1:";
    cin >> ans1;

As per the instructions of the homework, you need to terminate the program in this else statement.

You have the exact same issues in your switch statement. The only thing you will do differently there will be

case A:
  score += 10;
  break;
case B:
  score += 5;
  break;
case C:
  score += 8;
  break
//etc etc etc
default:
 //end the program
This article has been dead for over six months. Start a new discussion instead.