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.
Criteria for Grading
• 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
• Proper comments
• 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!
Menu
-----
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 2: Ali bin Mohamad
Please enter name 3: Surita a/p Muthu
Menu
-----
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
Please enter the level(B-Beginner, A-Advanced):B
Menu
-----
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
Wrong input! Please re-enter the answer.
? 1548u
Wrong input! Please re-enter the answer.
? 1548
Yes, you are right!
Your score is: 17
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
Wrong input! Please re-enter the answer.
? -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!
Your score is: 21
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
Wrong input! Please re-enter the answer.
? -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!
Your score is: 15
Menu
-----
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
Menu
-----
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 Ali bin Mohamad
2 Tan Ah Beng
3 Surita a/p Muthu
Menu
-----
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
Menu
-----
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
Please enter the level(B-Beginner, A-Advanced):a
Menu
-----
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
Wrong input! Please re-enter the answer.
? 25
Sorry, you are wrong!
Your score is: 15
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!
Your score is: 24
Menu
-----
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
Menu
-----
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
Menu
-----
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 . . .