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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started