Computers are playing an increasing role in education. Write aprogram that will
ID: 3609932 • Letter: C
Question
Computers are playing an increasing role in education. Write aprogram that will help an elementary school student learnmultiplication. Use a Random object to produce two positiveone-digit integers. The program should then prompt the user with aquestion, such as How much is 6 times 7? The student theninputs the answer. Next, the program checks the student's answer.If it is correct, display the message "Very Good!" and ask anothermultiplication question. If the answer is wrong, display themessage "No. Please try again." and let the student try the samequestion repeatedly until the student finally gets it right. Aseperate method should be used to generate each new question. Thismethod should be called once when the application begins executionand each time the user answers the question correctly.
Explanation / Answer
please rate - thanks this goes on forever. Let me know if it needs anymodification import java.util.*;public class multiply
{static int digit1,digit2,prod;
public static void main(String []args)
{int answer;
Random generator = new Random();
Scanner in = new Scanner(System.in);
while(true)
{gennumbers(generator);
do
{System.out.print("How much is "+digit1+" * "+digit2+"? ");
answer=in.nextInt();
if(answer==prod)
System.out.println("VeryGood! ");
else
System.out.println("No. Pleasetry again.");
}while(answer!=prod);
}
}
public static void gennumbers(Random generator)
{digit1 =Math.abs( generator.nextInt()%9)+1;
digit2 =Math.abs( generator.nextInt()%9)+1;
prod=digit1*digit2;
return;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.