-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java.bak
More file actions
44 lines (41 loc) · 899 Bytes
/
Game.java.bak
File metadata and controls
44 lines (41 loc) · 899 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
33
34
35
36
37
38
39
40
41
42
43
44
import java.util.Scanner;
class Game
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("------Welcome to the Number Guessing game----");
Boolean flag=true;
int count=0;
do
{
int num=(int)(Math.random()*9+9);
System.out.println(num);
System.out.println("enter your guessing");
int n=sc.nextInt();
if(n==num){
System.out.println("your guessing is correct and you found at "+count+" attemp");
}
else if(num>n){
System.out.println("Too Low....keep trying!");
count++;
}
else{
System.out.println("Too High....keep trying!");
count++;
}
System.out.println("Do you want to continue(1.yes/2.no)...");
int ne =sc.nextInt();
switch(ne){
case 1:
flag=true;
break;
case 2:
flag=false;
break;
}
}
while (flag);
System.out.println("thank you for playing this game:");
}
}