Skip to content

Commit 9146a02

Browse files
updated
1 parent 3ff6097 commit 9146a02

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

17MathStringPrintfAndFinal.java/Chalanges/areaAndCircumference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public String toString() {
3232

3333
public static void main(String[] args) {
3434
Scanner input = new Scanner(System.in);
35-
System.out.println("Welcome to Circle Worlds");
35+
System.out.println("Welcome to Circle World");
3636
System.out.println("Enter the circle radious : ");
3737

3838
double radius = input.nextDouble();
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import java.util.Scanner;
2+
3+
class guessingGame{
4+
int diceRandom;
5+
// int result;
6+
7+
public static int randomNum(){
8+
int diceRandom =(int) ((Math.random() * 6 + 1));
9+
return diceRandom;
10+
}
11+
12+
/*
13+
if guess number equal to random number get 1 marks.
14+
if guess number not equal random number get -1 marks
15+
16+
*/
17+
18+
19+
public static int resultShow (int diceRandom, int userNum){
20+
21+
if (diceRandom == userNum ) {
22+
return 1;
23+
}else{
24+
return -1;
25+
}
26+
}
27+
28+
29+
public static void main(String[] args) {
30+
Scanner input = new Scanner(System.in);
31+
System.out.println("Welcome to play guessing Game");
32+
System.out.println("Enter own Number between 1 to 6");
33+
34+
int userNum = input.nextInt();
35+
int systemNum = randomNum();
36+
37+
if (userNum >= 1 && userNum <= 6) {
38+
int Score = resultShow(systemNum, userNum);
39+
40+
if (Score == 1) {
41+
System.out.println("You Won");
42+
}else{
43+
System.out.println("You Lost");
44+
}
45+
46+
}else{
47+
System.out.println("You guess out of the T&C");
48+
}
49+
50+
input.close();
51+
52+
// guessingGame myGame = new guessingGame();
53+
// System.out.println(myGame.diceRandom);
54+
55+
56+
}
57+
58+
59+
}

0 commit comments

Comments
 (0)