First, you should set an appointment with a good optometrist; I for one don't read well top to bottom.
Secondly, where is the logic plan? where is the design where you take the requirements and lay them out in a logical order?
It looks a lot, to me, as though you have read the requirements, and then have started to code.
Since this is due to be finished in a few hours, then I would suggest that you take the requirements ( turn them so they are legible) and write on paper or notepad, each requirement.
Then group each one into a logical step or group of steps.
These 'steps' will be functions to be called by MAIN()
Within MAIN() , you can call each of these logical steps in order.
main() {
a()
b()
c()
printf(ans =,%d",ans);
}
a() // does the first fnc
return
b() // doesthe 2nd fnc
return
c()
return
d()
return
//eof
Don't forget to comment along the way, so that when you get stuck or it breaks for some unknown reason, then it'll be easy to focus on the WHERE.
Thanks. And here is what I have done so far. Please help me more. I almost fail the class and I will fail the class if I get a low grade on this homework hic hic . I have to due today, so please helppppppppppppppp. thank.
// Chapter7 # 9
#include <iostream>
#include <string>
using namespace std;
int main ()
{
const int QUESTIONS = 20;
cout << " Please enter your answer for question 1 to 20 " << endl;
for ( int i=0; i <20; i++)
{
cout << i+1 << ". ";
cin >> studentResponse [QUESTIONS];
}
int numberWrong;
int numberCorrect;
for ( int i = 0; i < 20; i++)
{
if ( answer [i] == studentResponse [i])
numberCorrect++;
}
cout << "You got " << numberCorrect << "correct. " << endl;
cout << " You got " << numberCorrect * 20 << " points" << endl;
cout << " You got " << 20-numberCorrect << " wrong. " << endl;
return 0;
}
You're using numberCorrect without initializing it.
Also, you don't seem to be using the numberWrong variable at all.
And cout << " You got " << 20-numberCorrect << " wrong. " << endl;
Not super important, but you may want to put QUESTIONS instead of 20 here. (doesn't really matter, since they're the same value, unless you ever decide to change the number of questions later)
#include <iostream>
#include <string>
using namespace std;
int main ()
{
const int QUESTIONS = 20; int numberWrong=0, numberCorrect=0;
char a_answer[QUESTIONS] = {'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
char a_studentResponse[QUESTIONS];
cout << " Please enter your answer for question 1 to 20 " << endl;
for ( int i=0; i<20; i++)
{
cout << i+1 << ".) "; cin >> a_studentResponse[i];
}
for ( int i = 0; i < 20; i++)
{
if ( a_answer[i] == a_studentResponse[i])
numberCorrect++;
}
Works fine 4 me.
move a var dec, and fix an array or two.
Suggest you compare the UPPER ( answer) to the UPPER of responce)
otherwise a student will FAIL if she answer in Lower-Case !
ps i didn't fix either of Long Dbl Main's suggestions - left that to you.
@ Long double main : Thanks for your suggestion ^^.
@ InCis B : I have to say that thank you sooooooooo much for your work. I realize what I am missing. Thanks again.