I am trying to make a JOptionPane get an input and assign it to an int but I am getting some problems with the variable types.
I am trying something like this:
// sample code for addition using JOptionPane
import javax.swing.JOptionPane;
public class Addition {
public static void main(String[] args) {
String firstNumber = JOptionPane.showInputDialog("Input ");
String secondNumber = JOptionPane.showInputDialog("Input ");
int num1 = Integer.parseInt(firstNumber);
int num2 = Integer.parseInt(secondNumber);
int sum = num1 + num2;
JOptionPane.showMessageDialog(null, "Sum is" + sum, "Sum of two Integers", JOptionPane.PLAIN_MESSAGE);
}
}