Hi all pros,
can anybody teach me write this programme in c++???

Problem Statement
Write a simple Mathematics quiz application which has six selections as below:
1) To register number of participants and name
2) To set level of difficulty (level: Beginner or Advanced)
3) To start the quiz (default: Beginner level)
4) To display the scores
5) To show ranking
6) To quit

Your program has to ask the user to key in the following details:
i) An integer (from 1 to 6) representing the program menu selection options.
ii) An integer (from 1 to 5) representing number of participants (maximum 5 participants).
iii) A character representing the level of difficulty: ‘B’ for Beginner; ‘A’ for Advanced.
a. Beginner level: Participants are required to answer as many questions as possible in 60 seconds. Questions involving addition, subtraction or multiplication operation are chosen randomly. The two operands in this level have to be set within 1 to 50 inclusive.
b. Advanced level: Participants are required to answer as many questions as possible in 60 seconds. Questions involving square or square root operation are chosen randomly. The operand for questions involving square ranges from 1 to 30 inclusive. The operand for questions involving square root ranges from 1 to 900 inclusive and must be a perfect square number.

Hints:
- For time, use difftime(time_t, time_t) function and include <ctime> header
- For random number, use rand() and include <cstdlib> header
E.g.
x = rand()%4, will result x from 0 to 3
x = rand()%4 + 1, will result x from 1 to 4
- Use ASCII code to display square root, √ and square, ²

iv) A character (any key) to start the quiz
v) A string representing the response to the quiz question.
User can either key in the answer for the question or key in ‘n’ to skip the question. If an invalid response is detected, user will be asked to re-enter the string until it is valid. The answer for the question will then be converted from string to integer so that it can be compared with the actual answer.
Each correct answer gives the participant 4 marks. 2 marks will be deducted for
each wrong answer. 1 mark will be deducted for each skipped question.
The scores analysis for the participants will then be tabulated and the participants will be ranked from the highest score to the lowest score.

• Loop your program so that the user will be asked to choose from the selection menu above after completing each selection task. Stop the loop only when the user select option 6 to quit.
• When the user quits the loop, display “Bye!”
• Your program must contain at least 8 functions excluding the main function.
• Do not use any global variables.
• Include as well necessary input validations/ error checking in the program.

Due Date: Thursday, 2 September 2010

Submission Requirements
A. Hardcopy:
1. Cover Page
2. Problem Statement
3. Program coding
4. Input and Output ( Include all possible results for all the options )
B. Softcopy of the program (upload to wble.utar.edu.my: e.g. leader_name.cpp) – before 2.00p.m.

• Syntactically correct
• Has input validations/ error checking
• Descriptive variable names
• Proper use of white space, well formatted output
• Proper and consistent indenting
• Correct and descriptive output
• Complete with requirements
• Original work
Your program should produce an output with the same format as the example shown below.

Example:

Welcome to Mathematics quiz!

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:1

Please enter the number of participants (1-5):3

Please enter name 1: Tan Ah Beng
Please enter name 3: Surita a/p Muthu

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:2

Beginner level : Questions involve addition, subtraction and multiplication
Advanced level : Questions involve square and square root

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:3

Tan Ah Beng, it's your turn. You have to answer as many questions as possible
within 60 seconds. Each correct answer gives you 4 marks. 2 marks will be deducted
for each wrong answer. You can skip a particular question by entering 'n', but 1
mark will be deducted for each question skipped. Press any key to start the quiz

3 x 13 =
? 39
Yes, you are right!

27 - 15 =
? 12
Yes, you are right!

30 - 8 =
? 22
Yes, you are right!

50 - 2 =
? 48
Yes, you are right!

29 x 24 =
? n
Question skipped!

43 x 1 =
? 433
Sorry, you are wrong!

43 x 36 =
? n2
? 1548u
? 1548
Yes, you are right!

Ali bin Mohamad, it's your turn. You have to answer as many questions as possible within 60 seconds. Each correct answer gives you 4 marks. 2 marks will be deducted for each wrong answer. You can skip a particular question by entering 'n', but 1 mark will be deducted for each question skipped. Press any key to start the quiz

49 + 35 =
? 84
Yes, you are right!

13 - 21 =
? -8
Yes, you are right!

32 + 30 =
? 62
Yes, you are right!

2 - 36 =
? -34r
? -34
Yes, you are right!

44 + 22 =
? 66
Yes, you are right!

1 x 28 =
? 28
Yes, you are right!

49 x 21 =
? n
Question skipped!

6 - 18 =
? 12
Sorry, you are wrong!

Surita a/p Muthu, it's your turn. You have to answer as many questions as possible within 60 seconds. Each correct answer gives you 4 marks. 2 marks will be deducted for each wrong answer. You can skip a particular question by entering 'n', but 1 mark will be deducted for each question skipped. Press any key to start the quiz

17 x 32 =
? n
Question skipped!

18 - 25 =
? -8
Sorry, you are wrong!

13 + 28 =
? 41
Yes, you are right!

20 - 48 =
? --28
? -28
Yes, you are right!

28 - 4 =
? 24
Yes, you are right!

50 + 24 =
? 64
Sorry, you are wrong!

50 x 4 =
? 200
Yes, you are right!

17 - 45 =
? -28
Yes, you are right!

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:4

Score List
----------
Correct Wrong Skipped Score
-------- -------- ---------- -------
Tan Ah Beng 5 1 1 17
Ali bin Mohamad 6 1 1 21
Surita a/p Muthu 5 2 1 15

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:5

Ranking List
------------
2 Tan Ah Beng
3 Surita a/p Muthu

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:1

Please enter the number of participants (1-5):2

Please enter name 1: Andy Lau
Please enter name 2: Shirley Wong Lai Har

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:2

Beginner level : Questions involve addition, subtraction and multiplication
Advanced level : Questions involve square and square root

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:3

Andy Lau, it's your turn. You have to answer as many questions as possible within 60 seconds. Each correct answer gives you 4 marks. 2 marks will be deducted for
each wrong answer. You can skip a particular question by entering 'n', but 1 mark will be deducted for each question skipped. Press any key to start the quiz

3² =
? 9
Yes, you are right!

√625 =
? 26
Sorry, you are wrong!

√16 =
? 4
Yes, you are right!

√81 =
? 9
Yes, you are right!

√9 =
? 3
Yes, you are right!

√729 =
? n
Question skipped!

15² =
? 225
Yes, you are right!

√256 =
? w
? 25
Sorry, you are wrong!

Shirley Wong Lai Har, it's your turn. You have to answer as many questions as possible within 60 seconds. Each correct answer gives you 4 marks. 2 marks will be deducted for each wrong answer. You can skip a particular question by entering 'n', but 1 mark will be deducted for each question skipped. Press any key to start the quiz

3² =
? 9
Yes, you are right!

14² =
? 196
Yes, you are right!

√841 =
? 29
Yes, you are right!

√225 =
? 15
Yes, you are right!

6² =
? 36
Yes, you are right!

√900 =
? 300
Sorry, you are wrong!

√529 =
? n
Question skipped!

√484 =
? n
Question skipped!

√729 =
? 27
Yes, you are right!

22² =
? 484
Yes, you are right!

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:4

Score List
----------
Correct Wrong Skipped Score
-------- -------- ---------- -------
Andy Lau 5 2 1 15
Shirley Wong Lai Har 7 1 2 24

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:5

Ranking List
------------
1 Shirley Wong Lai Har
2 Andy Lau

-----
1. To register number of participants and name
2. To set level of difficulty
3. To start the quiz (default: Beginner level)
4. To display the scores
5. To show ranking
6. To quit

Option:6

Bye!
Press any key to continue . . .

can anybody teach me write this programme in c++???

Yes. Provided you come to the table with something more than a copy/paste job of your assignment. What have you tried? Which part is stumping you? Can you put together a program that does some of the functions? etc.

What do you have so far?

The exact same questions has been asked to me and I tough time doing the part display scores and ranking..anyone could help me...This is what I have done so far..I dont know whether it is correct or not???

``````# include <stdio.h>
# include <ctype.h>
char name_registration();
char lvl_difficulty();
void display_scores(char);
int main()
{
int option;
char level,quit,name_1;
printf("\tWelcome To Simple Mathematics Quiz!!!!!!!!\n\a");

printf("\t\tMain Menu\n\a");                                                             //to show the options
printf("\t1. To register number of participants and names\n\a");
printf("\t2. To set level of Difficulty(B = Beginner or A = Advanced)\n\a");
printf("\t3. To start the quiz(default = Beginner level)\n\a");
printf("\t4. To display the scores\n\a");
printf("\t5. To show ranking\n\a");
printf("\t6. To quit\n\a");

scanf("%d",&option);

switch(option)
{
case 1 : name_registration();
break;
case 2 : lvl_difficulty();                                                //choosing the level of the Quiz
break;
case 3 : //quiz();                                                           //player plays the quiz
break;
case 4 : display_scores(name_1);                                           //displaying players scores
break;
case 5 : printf("\t\tRanking List\n\a");
break;
case 6 : printf("Bye!!!!!!!\n");                                                      //to quit the game
break;
default : printf("Please enter the RIGHT option!!!!!!!!!\n\a");
}
}
//function definition
char name_registration()
{
int no_of_participants;
char name_1[30] , name_2[30] , name_3[30] , name_4[30] , name_5[30];

printf("Please enter the number of participants (1-5):");
scanf("%d",&no_of_participants);

while(no_of_participants < 1 || no_of_participants > 5)
{
printf("Please enter the correct number of participants (1-5):");
scanf("%d",&no_of_participants);
fflush(stdin);
}

switch(no_of_participants)
{
case 1 : printf("Please enter name 1:");
scanf("%s",name_1);
fflush(stdin);
break;

case 2 : printf("Please enter name 1:\n");
scanf("%s",name_1);
fflush(stdin);
scanf("%s",name_2);
fflush(stdin);
break;

case 3 : printf("Please enter name 1:\n");
scanf("%s",name_1);
fflush(stdin);
scanf("%s",name_2);
fflush(stdin);
scanf("%s",name_3);
fflush(stdin);
break;

case 4 : printf("Please enter name 1:\n");
scanf("%s",name_1);
fflush(stdin);
scanf("%s",name_2);
fflush(stdin);
scanf("%s",name_3);
fflush(stdin);
scanf("%s",name_4);
fflush(stdin);
break;

case 5 : printf("Please enter name 1:\n");
scanf("%s",name_1);
fflush(stdin);
scanf("%s",name_2);
fflush(stdin);
scanf("%s",name_3);
fflush(stdin);
scanf("%s",name_4);
fflush(stdin);
scanf("%s",name_5);
fflush(stdin);
break;
}
return name_1,name_2,name_3,name_4,name_5;
}
char lvl_difficulty()
{
char level;
printf("Beginner level : Questions involve addition, subtraction and multiplication\n\a");
printf("Advanced level : Questions involve square and square root\n\a");
printf("Please enter a level(B = Beginner or A = Advanced) : ");
scanf("%c",&level);
return level;
}
void display_scores(char name_1)
{
int correct1,wrong1,skipped1,scores1;
correct1 = 12;
wrong1 = 3;
skipped1 = 2;
scores1 = 24;