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

Programmed in Java Multiplication GUI Create a GUI that functions like flash-car

ID: 3853057 • Letter: P

Question

Programmed in Java Multiplication GUI Create a GUI that functions like flash-cards to teach or test multiplication. Your software should: randomly selects two one-digit integers: display a multiplication problem based on the two integers, such as "3 times 7 = ": get the user's answer in a text box and parse it to an integer: display a message telling the user that the user was correct, or display a message telling the user the correct answer. You can use jLabels to display the problem and the messages.

Explanation / Answer

Here is the coding section of given criteria, please go through it thoroughly:-

import java.util.Random;
import javax.swing.JOptionPane;

public class MultiplicationGUI {
public static void main(String[] args) {

try {

Random random = new Random();
// code use to randomly selects the two single-digit numbers
int num_1 = random.nextInt(10);
int num_2 = random.nextInt(10);

// code used to enter the output
int userOutput = Integer.parseInt(JOptionPane.showInputDialog(num_1
+ " x " + num_2 + " = "));

// code used to check the users given output
if (userOutput == (num_1 * num_2)) {

JOptionPane.showMessageDialog(null, "Correct Answer");
} else {

JOptionPane.showMessageDialog(null, "Incorrect Answer:" + num_1
+ " x " + num_2 + " = " + (num_1 * num_2));
}

} catch (Exception e) {
// code use to handle exception
}

}
}

==============================

Please run these codes into your Java window and check out the output.

Feel free to contact us if you have any query.

Thankyou