Complete the following program to write the necessary HTML and
JavaScript code. The program will help an elementary school student
learn multiplication. The program is composed of 2 buttons, one
label as a question, one text box for the use answer, and one
paragraph for the feedback.
Once the user clicks the first button “Generate
Question”, the button must call a function named
“generate()” that will generate two integer random
numbers (n1 and n2)
between 1 and 10 (included). The numbers generated (n1 and n2) must
then be displayed in the label as a text question (see the output
example below) For example "What is n1 X n2?".
The user has to answer the multiplication of the two numbers and
write the results in the text box. Once the user clicks the button
“Check Answer”, then another function named
“check()” is called. This function will check if
the answer equals the multiplication of the random numbers
generated (n1 and n2) or not. If it’s correct, display the string
"Very good!". If the answer is wrong, display the
string "No. Please try again."
Note: you are ONLY required to continue the program by
writing: the form elements, the "generate()" function code,
and the "check()" function code.
The following output will guide you:
<!DOCTYPE html>
<html>
<head>
<title>Learn Multiplication</title>
<meta charset="utf-8" />
</head>
<body>
<script type="text/JavaScript">
var n1, n2; //n1 and
n2 are already declared
function generate()
{
//YOUR
ANSWER GOES HERE
}
function check()
{
//
YOUR ANSWER GOES HERE
}
</script>
<form action = "#">
// YOUR ANSWER
GOES HERE
</form>
</body>
</html>
Complete the following program to write the necessary HTML and JavaScript code. The program will help an elementary scho
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am