How to calculate the mark?

Hey guys, ignore the ridiculous question down there, i just trying to figure out how to calculate the mark after the user pick the abcd option and at the last program, the user will be show their result based on their options, example q1, the user pick a that represent 5 mark, and q2 the user pick b that represent 3 mark, how to show to the user that their score is 8 after the end of personality test session?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 #include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(void)
{
cout << "                                Personality Test Concept\n" << endl;
system("PAUSE");
string answer1,answer2,answer3,answer4,answer5;
bool valid = false; 

do {
system("CLS");
cout << "Question 1\n\n";
cout << "You love hangout?\n";

cout << "A.Yes I do.\nB.Sometimes.\nC.Rarely\nD.No\n\n";
cout << "Answer: ";
cin >> answer1;
valid = false; 

if (answer1 == "A" || answer1 == "a" ){
valid = true;
}	

	else if (answer1 == "B" || answer1 == "b"){
valid = true; 
} 
	else if (answer1 == "C" || answer1 == "c"){
valid = true; 
} 
	else if (answer1 == "D" || answer1 == "d"){
valid = true; 
} 

else {
cout << "That is an invalid answer!\n\n"
<< "Please type only A,a,B,b,C,c and D,d.\n";

system("PAUSE");
}
} while (!valid);

do {
system("CLS");
cout << "Question 2\n\n";
cout << "2.Do you like fish?\n";

cout << "A .Yes eat alot.\nB.sometime eat\nC.Everytime I eat fish\nD.no thank\n\n";
cout << "Answer: ";
cin >> answer1;
valid = false; 

if (answer1 == "A" || answer1 == "a" ){
valid = true;
}	

	else if (answer1 == "B" || answer1 == "b"){
valid = true; 
} 
	else if (answer1 == "C" || answer1 == "c"){
valid = true; 
} 
	else if (answer1 == "D" || answer1 == "d"){
valid = true; 
} 

else {
cout << "That is an invalid answer!\n\n"
<< "Please type only A,a,B,b,C,c and D,d.\n";

system("PAUSE");
}
} while (!valid);




}



i dont understand hard coding, just try give me the easiest coding as this only for some school/collegue task, thanks for those try to help! I will appreciate it so much because Im really blank right now! only god can repay your kindness!Hope with your help I gain new knowledge and for your benfits you can expand your knowledge too, cheers!
Last edited on
Make a counter. If A is always +5, B +3, C +1 (or somesuch) and D +0, make it so that if the answer is A, mark += 5, else if it's B, mark += 3, et cetera.
Ispil do u mind to make the additional coding inside my existed code? because Im really just a newbie T.T sorry if it disturb you, if you dont want, its ok and thanks for give me the info :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 #include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(void)
{
cout << "                                Personality Test Concept\n" << endl;
system("PAUSE");
string answer1,answer2,answer3,answer4,answer5;
int mark = 0;    //Variable to keep track of answer values
bool valid = false; 

do {
system("CLS");
cout << "Question 1\n\n";
cout << "You love hangout?\n";

cout << "A.Yes I do.\nB.Sometimes.\nC.Rarely\nD.No\n\n";
cout << "Answer: ";
cin >> answer1;
valid = false; 

if (answer1 == "A" || answer1 == "a" ){
valid = true;
mark += 5;    //For A, add 5 to mark
}	

	else if (answer1 == "B" || answer1 == "b"){
valid = true;
mark += 3;    //For B, add 3
} 
	else if (answer1 == "C" || answer1 == "c"){
valid = true;
mark += 1;    //For C, add 1
} 
	else if (answer1 == "D" || answer1 == "d"){
valid = true; 
} 

else {
cout << "That is an invalid answer!\n\n"
<< "Please type only A,a,B,b,C,c and D,d.\n";

system("PAUSE");
}
} while (!valid);
return 0;
}


Mind you, that is only for the first question. The rest should be about the same.
Last edited on
so ispil, how bout the last calculation? example to show the user that they got 8? q1+q2 cout"total personality test for you is: "? sorry to disturb u again==

edit: actually i feel shy to ask the question again and again to u because im afraid that will make you annoying, but i left no choice, sorry, and its ok if you tell me that you cant help me, i understand.
Last edited on
anybody tat can shared the knowledge for such a newbie? bump
finally got it. thanks ispil.
Topic archived. No new replies allowed.