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

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879`` `````` #include #include #include 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 :)
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748`` `````` #include #include #include 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.