Concepts used: Random number generation, definite loop, counter variable, modular programming using functions (aka methods), string data (very basic), many-way decision making.
This assignment asks you to design and implement a program that could be used for testing grade school students knowledge of multiplication tables.
The program will operate as follows:
1. The program will greet the student and ask for his/her first name. This name will be read into a string variable and would be used later as part of the report generated.
2. Then the program will present one multiplication table question at a time to the student, using a count controlled loop. The loop will run 10 times, but a named constant should be used to hold that value. The named constant should be used (rather that the literal constant 10) whenever that number is needed for loop control or calculations. The program will generate two random numbers (between 1 and 10) and pose the problem for those numbers like this:
What is 7 times 9 ?
The program then reads the answer typed by the student and compares it to the answer it calculates and provides one of two possible messages:
Your answer is correct!
or,
Your answer is wrong! The correct answer is 63.
3. Once the student has answered all the problems, the program will display a summary report for the student. The report will include:
In a lab, we used the following statement to generate a value between 1 and 6:
face = 1 + rand.nextInt(NUM_FACES);
where rand is a random number generator. The rand.nextInt(NUM_FACES) method generates a random integer value between 0 and NUM_FACES 1 (with NUM_FACES = 6), so face will have a value between 1 and 6. So to generate a random integer (an integer value between 1 and 10) we can use the expression
1 + rand.nextInt(10)
with appropriate declarations.
The program will use several functions (methods) to divide the problem into parts that can be solved separately. The following functions are required to be present:
You may design and use more functions as you see fit.
The diagram here shows which function(s) call which other function(s). see image.