Przeglądaj źródła

TooLargeTooSmall

Chaitali Patel 8 lat temu
rodzic
commit
22fad4684c
5 zmienionych plików z 70 dodań i 4 usunięć
  1. BIN
      Main.class
  2. 5
    0
      Main.ctxt
  3. 21
    4
      Main.java
  4. 12
    0
      README.TXT
  5. 32
    0
      package.bluej

BIN
Main.class Wyświetl plik


+ 5
- 0
Main.ctxt Wyświetl plik

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=Main
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+numComments=2

+ 21
- 4
Main.java Wyświetl plik

@@ -1,9 +1,26 @@
1 1
 /**
2 2
  * Created by iyasuwatts on 10/17/17.
3 3
  */
4
+import java.util.*;
4 5
 public class Main {
5
-
6 6
     public static void main(String[] args){
7
-        
8
-    }
9
-}
7
+        Scanner keyboard = new Scanner(System.in);
8
+        boolean isCorrect = false;
9
+        int n=0;
10
+        while(isCorrect==false) {
11
+            System.out.println("Guess a mystery number!");
12
+            int randNumber=(int)(Math.random()*10+1);//generating a random number
13
+            int number = keyboard.nextInt();//user input
14
+             if(number == randNumber) {
15
+                System.out.println("correct guess");
16
+                isCorrect = true;
17
+            }else if(number>=randNumber){
18
+                System.out.println("too large");
19
+            } else{
20
+                System.out.println("too small");
21
+            } 
22
+            n++;
23
+        }
24
+       System.out.println(n);
25
+    } 
26
+}

+ 12
- 0
README.TXT Wyświetl plik

@@ -0,0 +1,12 @@
1
+------------------------------------------------------------------------
2
+This is the project README file. Here, you should describe your project.
3
+Tell the reader (someone who does not know anything about this project)
4
+all he/she needs to know. The comments should usually include at least:
5
+------------------------------------------------------------------------
6
+
7
+PROJECT TITLE:
8
+PURPOSE OF PROJECT:
9
+VERSION or DATE:
10
+HOW TO START THIS PROJECT:
11
+AUTHORS:
12
+USER INSTRUCTIONS:

+ 32
- 0
package.bluej Wyświetl plik

@@ -0,0 +1,32 @@
1
+#BlueJ package file
2
+editor.fx.0.height=0
3
+editor.fx.0.width=0
4
+editor.fx.0.x=0
5
+editor.fx.0.y=0
6
+objectbench.height=101
7
+objectbench.width=776
8
+package.divider.horizontal=0.6
9
+package.divider.vertical=0.8007380073800738
10
+package.editor.height=427
11
+package.editor.width=674
12
+package.editor.x=266
13
+package.editor.y=260
14
+package.frame.height=600
15
+package.frame.width=800
16
+package.numDependencies=0
17
+package.numTargets=1
18
+package.showExtends=true
19
+package.showUses=true
20
+project.charset=UTF-8
21
+readme.height=58
22
+readme.name=@README
23
+readme.width=47
24
+readme.x=10
25
+readme.y=10
26
+target1.height=50
27
+target1.name=Main
28
+target1.showInterface=false
29
+target1.type=ClassTarget
30
+target1.width=80
31
+target1.x=70
32
+target1.y=10