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

Code needs to be written in Java. Thanks for any help! The use of computers in e

ID: 3690214 • Letter: C

Question

Code needs to be written in Java. Thanks for any help!

The use of computers in education is referred to as computer-assisted instruction. Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers. The program should then display a question such as: "How much is 6 times 7"? The student types the answer and your program validates the student's answer. If it is correct, display a message "Very Good!" and asks another multiplication question. If the student's input is incorrect, display a message "No. Please try again" and let the student try the same question repeatedly until the student finally gets it right. A separate method should be used to generate each new question. This method should be called once when the application begins execution and each time the user answers the question correctly.

Explanation / Answer

// Code start here

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package javaapplication2;

// import some java package here

import java.util.Random;

import java.util.Scanner;

/**

*

* @author ramesh

*/

public class JavaApplication2 {

/**

* This function use for create new random question.

*/

public static int[] RandomQuestion(){

// Create random objecct here

Random ran = new Random();

// define question array here

int Qusarr[] = new int[2];

Qusarr[0] = ran.nextInt(9);

Qusarr[1] = ran.nextInt(9);

// return question

return Qusarr;

}

// this is main function

public static void main(String args[]) {

// Create scanner object here

Scanner userinput = new Scanner(System.in);

int Qus[] = new int[2];

int userAnswer;

String userNext;

// start do while loop here

do{

// call RandomQuestion() method here

Qus = RandomQuestion();

/*

* Try and chatck use for check user input vaild intager and not

* If user not enter valid intager then show message and show next question message

*/

try {

/*

* Start inner do while loop here.

* This loop run if question answer not right.

*/

do{

// Show question here

System.out.print(" How much is " + Qus[0] + " times " + Qus[1] + " ? :");

// get user answer

  

userAnswer = userinput.nextInt();

// if you want current question answer then uncomment this line.

//System.out.print((Qus[0]*Qus[1]));

/*

* Check answer right and not.

* If question answer is right then show very good message

* If question answer incorrect then show No.Please try again. mesage

*/

if(userAnswer == (Qus[0]*Qus[1])){

System.out.print(" Very Good!");

}else{

System.out.print(" No.Please try again.");

}

  

}while(userAnswer != (Qus[0]*Qus[1]));

} catch (Exception e) {

System.out.println("The value you have input is not a valid integer");

}

// show message for user. user want next question or stop.

System.out.print(" Do you want more questions(y/n) :");

// Get user input

userinput.nextLine();

userNext = userinput.nextLine();

}while(userNext.equalsIgnoreCase("y"));

}

  

}

// Code end here

Output here:-

How much is 8 times 7 ? : 45

No. Please try again

How much is 8 times 7 ?: 56

very Good!

Do you want next questions(y/n): y

How much is 3 times 2 ? :

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