Question: Create a Dynamic Web Project in Eclipse, then create a servlet called AdditionPractice as follows: In doGet(), generate two random numbers between 1 and 9,
Create a Dynamic Web Project in Eclipse, then create a servlet called AdditionPractice as follows:
In doGet(), generate two random numbers between 1 and 9, and display a form that asks the user to enter the sum of the two numbers. For example, suppose the two random numbers are 8 and 2, the form should look like the following:
8 + 2 = textbox Submit button
You can use nextInt(int bound) method in Random to generate the random numbers.
In doPost(), display the correct answer, the user's answer, and tell the user if their answer is correct. For example, suppose the user entered the answer 9, the display should be:
8 + 2 = 10
Your answer 9 is incorrect.
Try Again
Clicking on Try Again should take the user back to the form with two new numbers.
The proper way to do this is to embed the two numbers in the form generated by doGet() using two hidden form fields, so they will be submitted to doPost() together with the user's answer.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
