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

Please answer this time, i\'ve asked like 4 times. Need it in java with eclipse.

ID: 654516 • Letter: P

Question

Please answer this time, i've asked like 4 times. Need it in java with eclipse.

Design an application that, when a button is pushed, will randomly select two numbers, from 1 to 20. The two numbers will be placed in an arithmetic expression and a text field will be used for the user to enter their answer to the math problem. A second button will be pushed when they are finished and should give the user feedback as to whether or not they had the correct answer. An example would look similar to:

Your application should contain two classes. One class should extend JPanel and contain the buttons, labels, and text field. The other class should establish the frame and add the panel.

Math Practice New Problem 10 13 23 Good job! Check Answer

Explanation / Answer

package p1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.Random;
public class math{
   JButton Problem,check;
   JTextField textbox;
   int result=0;
   public static void main(String[] args) {
           math gui = new math();
          
           gui.go();
       }
  
       public void go() {
          
           JFrame frame = new JFrame("Math Pratice");
           JPanel pane = new JPanel();
           Random rn=new Random();
           int n1=rn.nextInt(9 + 1) + 1;
            int n2=rn.nextInt(9 + 1) + 1;
      
          
           //Create Buttons
           Problem = new JButton(" New Problem ");
           setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
           add(new Label(n1+"+"+n2+"="));
           textbox = new JTextField(10);   //Create TextBox
            check = new JButton(" Check Answer ");
          
          //create active listeners
           //Problem.addActionListener(new ProblemButton());
           //check.addActionListener(new checkButton());
          
           //Create layout
           frame.getContentPane().add(BorderLayout.NORTH, textbox);
           frame.getContentPane().add(BorderLayout.CENTER, pane);
          
           //Set sizes and defaults
           frame.setSize(275, 290);
           frame.setVisible(true);
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       }
       class EqualsButton implements ActionListener {
           public void actionPerformed(ActionEvent event) {
               int res = Integer.parseInt(textbox.getText());
                   if(math.n1+math.n2==res) {
                       setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
                       add(new Label("Good job!"));

                   } else {
                       setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
                       add(new Label("Wrong !"));

                   }
  
           }
       }
       public void setLayout(FlowLayout flowLayout) {
           // TODO Auto-generated method stub
          
       }

       public void add(Label label) {
           // TODO Auto-generated method stub
          
       }
}


A few changes may be required.