-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIassignment.java
More file actions
41 lines (29 loc) · 1.41 KB
/
Copy pathGUIassignment.java
File metadata and controls
41 lines (29 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import javax.swing.JOptionPane;
public class GUIassignment{
public static void main(String[] args) {
int Num1;
Num1 = Integer.parseInt(JOptionPane.showInputDialog("What is the first number?"));
int Num2;
Num2 = Integer.parseInt(JOptionPane.showInputDialog("What is the second number?"));
int Num3;
Num3 = Integer.parseInt(JOptionPane.showInputDialog("What is the third number?"));
int Total;
Total = Num1 + Num2 + Num3;
JOptionPane.showMessageDialog(null, "The total is " + Total);
}
}
// import javax.swing.JOptionPane;
// public class GUIassignment {
// public static void main(String[] args) {
// // Prompt user for the first number and convert it to int
// int Num1 = Integer.parseInt(JOptionPane.showInputDialog("What is the first number?"));
// // Prompt user for the second number and convert it to int
// int Num2 = Integer.parseInt(JOptionPane.showInputDialog("What is the second number?"));
// // Prompt user for the third number and convert it to int
// int Num3 = Integer.parseInt(JOptionPane.showInputDialog("What is the third number?"));
// // Calculate the total
// int Total = Num1 + Num2 + Num3;
// // Display the total in a dialog box
// JOptionPane.showMessageDialog(null, "The total is " + Total);
// }
// }