-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice_2.java
More file actions
32 lines (26 loc) · 952 Bytes
/
Copy pathPractice_2.java
File metadata and controls
32 lines (26 loc) · 952 Bytes
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
import java.nio.channels.ShutdownChannelGroupException;
import javax.swing.JOptionPane;
/*
* Make a program that asks the user how many bedrooms their house has.
* Give them the following response based on their input
*
* less than 0 : Give them an error
* equal to 0 : Come stay at my place!
* one to three : That's cool
* greater than 3 : You have a big house!
*/
public class Practice_2 {
public static void main(String[] args) {
String x = JOptionPane.showInputDialog(null, "How many bedrooms do you have in your house?");
int numRooms = Integer.parseInt(x);
if(numRooms < 0) {
JOptionPane.showMessageDialog(null, "Error, Try Again");
} else if(numRooms == 0) {
JOptionPane.showMessageDialog(null, "Come stay at my place");
} else if(numRooms >= 1 && numRooms <= 3) {
JOptionPane.showMessageDialog(null, "That's Cool!");
} else if (numRooms > 3) {
JOptionPane.showMessageDialog(null, "You have a big house!");
}
}
}