File tree Expand file tree Collapse file tree
17MathStringPrintfAndFinal.java/Chalanges Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ();
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments