Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, Can you please make the cancel button in this program clear the user's input? import javax.swing.JOptionPane; /** * * @author user */ public class

Hello,

Can you please make the cancel button in this program clear the user's input?

import javax.swing.JOptionPane;

/** * * @author user */ public class AddIntegers { public AddIntegers() { String userInput = "yes"; while (userInput.equalsIgnoreCase("yes")) { try { String userInput1 = JOptionPane.showInputDialog ("Please enter an integer. "); String userInput2 = JOptionPane.showInputDialog ("Please enter another integer. "); int userInt1 = Integer.parseInt(userInput1); int userInt2 = Integer.parseInt(userInput2); System.out.println(); userInput = JOptionPane.showInputDialog ("The sum of the two numbers you entered in is: " + (userInt1 + userInt2) + " The product of the two numbers you entered in is: " + (userInt1 * userInt2) + " If you want to add and multiply two new integers," + " press yes (case does not matter). If not," + " press anything else. "); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Please enter int numbers " + "only."); } } } }

Thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions