-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathriddleme.java
More file actions
31 lines (26 loc) · 1.18 KB
/
Copy pathriddleme.java
File metadata and controls
31 lines (26 loc) · 1.18 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
import javax.swing.JOptionPane;
public class riddleme {
public static void main(String[] args) {
// 1. Make a variable to hold the score
int score = 0;
// 3. Ask the user a riddle. Here are some ideas: bit.ly/the-riddler
String riddle1 = JOptionPane
.showInputDialog("What gets wetter as it dries?");
// 4. If they got the answer right, pop up "correct!" and increase the
// score by one
if (riddle1.equals("a towel")) {
JOptionPane.showMessageDialog(null, "Correcto!");
score += 1;}
else { JOptionPane.showMessageDialog(null, "Wrong!"); score -= 1;
JOptionPane.showMessageDialog(null, "Answer: a towel");}
JOptionPane.showMessageDialog(null, "Score: " + score);
String riddle2 = JOptionPane.showInputDialog("Why did chica cross the road?");
if (riddle2.equals("To get to the other pizza.")) {
JOptionPane.showMessageDialog(null, "Correcto!"); score += 1;
}
else { JOptionPane.showMessageDialog(null, "Wrong!"); score -= 1;
JOptionPane.showMessageDialog(null, "Answer: To get to the other pizza.");}
JOptionPane.showMessageDialog(null, "Score: " + score) ;
JOptionPane.showMessageDialog(null, "I hope you liked meh jokes :D");
}
}