-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge5.java
More file actions
45 lines (44 loc) · 1.49 KB
/
challenge5.java
File metadata and controls
45 lines (44 loc) · 1.49 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
42
43
44
45
/**
* Write a description of class challenge5 here.
*
* @author (Kate V.)
* @version (June 1st, 2020)
*/
import java.util.*;
public class challenge5
{
public static void main()
{
System.out.println("You and your friend are discussing the physics test that you did today. \nHe is curious and asks you: “Hey since you are saying that you’re so good in physics, answer me this. Can air make shadows?” \nType yes or no");
Scanner someScanner = new Scanner(System.in);
String ans = someScanner.nextLine().toLowerCase();
while (!ans.equals("yes"))
{
if(ans.equals("no"))
{
System.out.println("Try again!");
ans = someScanner.nextLine();
}
if(ans.equals("exit"))
{
System.exit(1);
}
else if(ans.equals("help"))
{
if(Hints.getnumOfHints() != 0)
{
System.out.println("The answer is opposite of yes (I know it's not a clue, but still");
Hints.numOfHints--;
ans = someScanner.nextLine();
}
else
{
System.out.println("Sorry, but you ran out of hints. Good luck!");
ans = someScanner.nextLine();
}
}
}
System.out.println("Huh, you are indeed pretty smart, okay!");
return;
}
}