|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
|
2
|
+/**
|
|
3
|
+ * Write a description of class twoBTwoS here.
|
|
4
|
+ *
|
|
5
|
+ * @author Khalil Saboor
|
|
6
|
+ * @version (a version number or a date)
|
|
7
|
+ */
|
|
8
|
+import java.util.*;
|
|
9
|
+public class twoBTwoS
|
|
10
|
+{
|
|
11
|
+ /**
|
|
12
|
+ * Constructor for objects of class twoBTwoS
|
|
13
|
+ */
|
|
14
|
+ public twoBTwoS()
|
|
15
|
+ {
|
|
16
|
+ int mysteryNumber = 5;
|
|
17
|
+ int count = 0;
|
|
18
|
+ boolean win = true;
|
|
19
|
+
|
|
20
|
+ Scanner input = new Scanner(System.in);
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+ do{
|
|
24
|
+ System.out.println("This is a guessing game");
|
|
25
|
+ System.out.println("to find the mystery number please enter a number:");
|
|
26
|
+ int number = input.nextInt();
|
|
27
|
+ if(number == 5){
|
|
28
|
+ System.out.println("You Win!!!");
|
|
29
|
+ System.out.println("You guess correctly");
|
|
30
|
+ System.out.println("The mystery number was "+ mysteryNumber);
|
|
31
|
+ System.out.println("You have guess "+ count + " times");
|
|
32
|
+ win = true;
|
|
33
|
+ break;
|
|
34
|
+ } else if(number < 5){
|
|
35
|
+ System.out.println("The number you entered is too low");
|
|
36
|
+ } else if(number > 5){
|
|
37
|
+ System.out.println("The number you entered is too high");
|
|
38
|
+ }
|
|
39
|
+ count++;
|
|
40
|
+ System.out.println("You have guess "+ count + " times");
|
|
41
|
+ System.out.println("Please try again:");
|
|
42
|
+ }while(mysteryNumber == 5);
|
|
43
|
+ }
|
|
44
|
+}
|