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

i have my code here and i need to add to it original assignment was to ask user

ID: 3645817 • Letter: I

Question

i have my code here and i need to add to it original assignment was to ask user to answer 2 random integers and if they get it correct it will tell them if they want another one but if its incorrect then it will tell them correct answer- but in this assignment it has to let the user answer till there correct and also let them choose from a menu using the joption if they want addition , subtraction or multiplication

//math program that assigns 2 random integers and user answers then correctly/incorrectly and will tell them the answer and ask if they wish to continue
** requirements **
Modify Assignment#4 by allowing user to select an addition, subtraction or multiplication.

Below shows Assignment#4.
Computers are playing an increasing role in education. Write a program that will help an
elementary school student learn multiplication. Use Math.random to produce two positive one-digit integers. It should then display a question such as:
How much is 6 times 7?
The student then types the answer and your program validates the student's answer. If it is correct, display a message "Very Good!" and then ask if the student wants another multiplication question.
If the student

Explanation / Answer

import javax.swing.JOptionPane; import java.util.Scanner; public class Assignment4{ public static void main(String[] args) { JOptionPane.showMessageDialog(null, "Ple"); int sum =0; // Keep reading data until the user answers No int option = JOptionPane.YES_OPTION; while (option == JOptionPane.YES_OPTION) { // will display random numbers up to 12 int number1= (int)(Math.random() * 12); int number2= (int)(Math.random() * 12); String choice=JOptionPane.showInputDialog("enter 'a' for Addition,'m' for multiplication,'s' for subtraction"); if(choice.equals("m")) { // will ask user to answer the total of the 2 random numbers String dataString = JOptionPane.showInputDialog ("What is "+number1 + " * " +number2 + " ? "); sum= number1 * number2; Scanner input = new Scanner(System.in); int data = Integer.parseInt(dataString); sum = data; // this will check to see if answer is correct or incorrect // will display message based on answer if (number1 * number2 == sum) JOptionPane.showMessageDialog(null, "You answered " + sum + " which is correct "); else JOptionPane.showMessageDialog(null, "You are incorrect, the correct answer is " + (number1 * number2)); // will ask user if they wish to continue after they have answered the question option = JOptionPane.showConfirmDialog(null, "Would you like another question?"); } else if(choice.equals("s")) { // will ask user to answer the total of the 2 random numbers String dataString = JOptionPane.showInputDialog ("What is "+number1 + "- " +number2 + " ? "); int diff= number1-number2; Scanner input = new Scanner(System.in); int data = Integer.parseInt(dataString); diff=data; // this will check to see if answer is correct or incorrect // will display message based on answer if ((number1 - number2) == diff) JOptionPane.showMessageDialog(null, "You answered " + diff + " which is correct "); else JOptionPane.showMessageDialog(null, "You are incorrect, the correct answer is " + (number1 - number2)); // will ask user if they wish to continue after they have answered the question option = JOptionPane.showConfirmDialog(null, "Would you like another question?"); } else if(choice.equals("a")) { // will ask user to answer the total of the 2 random numbers String dataString = JOptionPane.showInputDialog ("What is "+number1 + " + " +number2 + " ? "); sum= number1 + number2; Scanner input = new Scanner(System.in); int data = Integer.parseInt(dataString); sum = data; // this will check to see if answer is correct or incorrect // will display message based on answer if ((number1 + number2) == sum) JOptionPane.showMessageDialog(null, "You answered " + sum + " which is correct "); else JOptionPane.showMessageDialog(null, "You are incorrect, the correct answer is " + (number1 + number2)); // will ask user if they wish to continue after they have answered the question option = JOptionPane.showConfirmDialog(null, "Would you like another question?"); } } } }