Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Write a JSP program that generates 5 math questions randomly, as shown in t

ID: 654663 • Letter: J

Question

Java

Write a JSP program that generates 5 math questions randomly, as shown in the figure below. The numbers must be two-digit numbers generated randomly. And the arithmetic operators (+, -, * and /) are also selected randomly for each question.

Name: <textbox for user to enter his name>

5 + 6 =

8 * 7 =

7 - 3 =

5 / 5 =

<reset button> <submit button>

After the user answers all questions and clicks Submit button, the JSP displays the result, as shown in the figure below. The user can also click Reset button to start over the quiz and new 5 questions will be regenerated.

after you submit it should look like below,

Name: Adam

5 + 6 = 11

8 * 7 = 12

7 - 3 = 4

5 / 5 = 1

<reset button> <submit button>

Adam got 3 answers correct

Please help me with this, i will give as many points as the system allows. thanks alot.

Explanation / Answer

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.*;" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- save as a Arithmetic.jsp program
contain different arithmetic operation-->
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8">
<title>R4R Tech Soft</title>
</head>
<body>
<h1>
  Hello R4R Tech Soft! Arithmetic Operation</h1>
<!javascript is used for checked the validation>
<script>
function check(){
if(document.Arithmetic.firstDigit.value==null|
    |document.Arithmetic.firstDigit.value=="")
{
alert("Please Enter the value of X:");
return false;
}else
if(document.Arithmetic.secondDigit.value==null||
    document.Arithmetic.secondDigit.value=="")
{
alert("Please Enter the value of Y:");
return false;
}
else{document.Arithmetic.submit();}
}
</script>
<form action="#" name="Arithmetic">

<BR>Enter the first digit: X
<input type="text" name="firstDigit" value="" size="20" >
<BR><BR>Enter the second digit: Y
<input type="text" name="secondDigit" value="" size="20" >
<BR><BR>
&nbsp;&nbsp; <input type="submit" value=" submit"
  name="submit">
</form>
<%
if (request.getParameter("submit") != null) {
//Take the value of x & y and Type Conversion
String s = (String) request.getParameter("firstDigit");
int x = Integer.parseInt(s);
String s1 = (String) request.getParameter("secondDigit");
int y = Integer.parseInt(s1);
//Arithmetic operation
int Sum = x + y;
{
out.println("<BR> Additon of X and Y = " + Sum);
int Substraction = x - y;
out.println("<BR> Substraction of X and Y = "
      + Substraction);
float Division = x / y;
out.println(" <BR>Division of X and Y = "+ Division);
int Mulitplication = x * y;
out.println("<BR> Mulitplication of X and Y = "
       + Mulitplication);
out.print("<br/>");
}
out.print("<BR>");
for (int i = 0; i <= x; i++) {
if ((i % 2) == 0) {
out.print(" Even number of X : " + i);
out.print("<br>");
}
}
out.print("<BR>");
for (int i = 0; i <= x; i++) {
if ((i % 2) != 0) {
out.print(" Odd number of X :" + i);
out.print("<br>");
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote