Tutorial 2: Create a Timed Math Quiz
In this tutorial, you build a quiz in which the quiz taker must answer four random arithmetic problems within a specified time. You learn how to:
-
Generate random numbers by using the Random class.
-
Trigger events to occur at a specific time by using a Timer control.
-
Control program flow by using if else statements.
-
Perform basic arithmetic operations in code.
When you finish, your quiz will look like the following picture, except with different numbers.
Quiz that you create in this tutorial

To download a completed version of the quiz, see Complete Math Quiz tutorial sample.
Note |
|---|
This tutorial covers both Visual C# and Visual Basic, so focus on the information that's specific to the programming language that you're using. |
|
Title |
Description |
|---|---|
|
Start by creating the project, changing properties, and adding Label controls. |
|
|
Create an addition problem, and use the Random class to generate random numbers. |
|
|
Add a countdown timer so that the quiz can be timed. |
|
|
Add a method to check whether the quiz taker entered a correct answer for the problem. |
|
|
Step 5: Add Enter Event Handlers for the NumericUpDown Controls |
Add event handlers that make your quiz easier to take. |
|
Add a subtraction problem that generates random numbers, uses the timer, and checks for correct answers. |
|
|
Add multiplication and division problems that generate random numbers, use the timer, and check for correct answers. |
|
|
Try other features, such as changing colors and adding a hint. |
Note