-
Notifications
You must be signed in to change notification settings - Fork 0
/
hangman_game.java
68 lines (62 loc) · 2.75 KB
/
hangman_game.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.Scanner;
public class hangman_game {
public static void main(String[] args)
{
String n = "HELLO";
String n1 = "CODING";
String n2 = "JAVA";
String n3 = "PROGRAMMING";
String n4 = "COMPUTER";
String n5 = "DELL";
Scanner scanner = new Scanner(System.in);
System.out.println("H__LO");
System.out.println("ENTER THE WORD : ");
String nn = scanner.next();
if (nn.equals(n)) {
System.out.println("Congratulations, let's go to the second question >>>>>>>");
System.out.println("C__I_G");
System.out.println("ENTER THE WORD : ");
String nn1 = scanner.next();
if (nn1.equals(n1)) {
System.out.println("Congratulations, let's go to the third question >>>>>>>");
System.out.println("J_V_A");
System.out.println("ENTER THE WORD : ");
String nn2 = scanner.next();
if (nn2.equals(n2)) {
System.out.println("Congratulations, let's go to the fourth question >>>>>>>");
System.out.println("P________NG");
System.out.println("ENTER THE WORD : ");
String nn3 = scanner.next();
if (nn3.equals(n3)) {
System.out.println("Congratulations, let's go to the fifth question >>>>>>>");
System.out.println("C________");
System.out.println("ENTER THE WORD : ");
String nn4 = scanner.next();
if (nn4.equals(n4)) {
System.out.println("Congratulations, let's go to the last question >>>>>>>");
System.out.println("D___");
System.out.println("ENTER THE WORD : ");
String nn5 = scanner.next();
if (nn5.equals(n5)) {
System.out.println("Congratulations, you won!");
} else {
System.out.println("Wrong guess, try again!");
}
} else {
System.out.println("Wrong guess, try again!");
}
} else {
System.out.println("Wrong guess, try again!");
}
} else {
System.out.println("Wrong guess, try again!");
}
} else {
System.out.println("Wrong guess, try again!");
}
} else {
System.out.println("Wrong guess, try again!");
}
scanner.close();
}
}