Input/Output using JOptionPane (GUI method)
import javax.swing.JOptionPane;
class InputGUI {
public static void main(String[] args) {
byte num1 =
Byte.parseByte(
JOptionPane.showInputDialog(
null, "Enter first number", "0")
);
byte num2 =
Byte.parseByte(
JOptionPane.showInputDialog(
null, "Enter second number", "10")
);
JOptionPane.showMessageDialog(null,
"Sum of " + num1 + " and " + num2 + " is " + (num1 + num2));
}
}
class InputGUI {
public static void main(String[] args) {
byte num1 =
Byte.parseByte(
JOptionPane.showInputDialog(
null, "Enter first number", "0")
);
byte num2 =
Byte.parseByte(
JOptionPane.showInputDialog(
null, "Enter second number", "10")
);
JOptionPane.showMessageDialog(null,
"Sum of " + num1 + " and " + num2 + " is " + (num1 + num2));
}
}
Comments
Post a Comment
Post Your Valuable Comments