K so Im supposed to create a loop where when the students answersmatch the test
ID: 3615721 • Letter: K
Question
K so Im supposed to create a loop where when the students answersmatch the test answers the student gets 2 points, loses a pt whenthe wrong choice is entered but nothing happens when a blank inentered.I have most of it working but not the loop. Any help plz
#include<iostream>
using namespace std;
int main()
{char answers[]="TFFTFFTTTTFFTFTFTFTT";
char studanswer[20];
int question,score,ID,grade;
score=0;
cout<<"Please enter the student's ID number ";
cin>>ID;
cout<<"Please enter the student's answers ";
cin>>studanswer;
cin.getline(studanswer,20);
for (question=0;question<20;question++);
{if (answers[question]==studanswer[question])
score=score+2;
else
if(studanswer[question]!=' ')
score=score--;
}
cout<<"student number "<<ID<<" Has scored a"<<score;
switch((int)score/10)
{case 10:
case 9:cout<<"The student's grade is an A";
case 8:cout<<"The student's grade is a B";
case 7:cout<<"The student's grade is a C";
case 6:cout<<"The student's grade is a D";
default :cout<<"The student's grade is a F";}
system ("pause");
return 0;}
Explanation / Answer
please rate - thanks The corrections are in red -- you have a stray; #include using namespace std; int main() {char answers[]="TFFTFFTTTTFFTFTFTFTT"; char studanswer[20]; int question,score,ID,grade; score=0; coutID; coutstudanswer; cin.ignore(10,' '); cin.getline(studanswer,20); for (question=0;questionRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.