Ver código fonte

Created coniditonal to check against Alice and Bob/ Print greetings to Alice & Bob

Elliott Stansbury 6 anos atrás
pai
commit
50a61d348d
2 arquivos alterados com 15 adições e 4 exclusões
  1. 13
    2
      Main.java
  2. 2
    2
      package.bluej

+ 13
- 2
Main.java Ver arquivo

@@ -1,9 +1,20 @@
1
+import java.util.Scanner;
1 2
 /**
2 3
  * Created by iyasuwatts on 10/17/17.
3 4
  */
4 5
 public class Main {
5 6
 
6
-    public static void main(String[] args ){
7
-
7
+    public static void main( ){
8
+        Scanner user_input = new Scanner( System.in );
9
+        
10
+        System.out.print("What is your name? ");
11
+        String name = user_input.next();
12
+        
13
+        if(name.equals("Bob") || name.equals("Alice")) {
14
+            System.out.println("Hello there " + name);
15
+        } else{
16
+            System.out.println("Im sorry I don\'t know you");   
8 17
     }
18
+    
19
+}
9 20
 }

+ 2
- 2
package.bluej Ver arquivo

@@ -9,8 +9,8 @@ package.divider.horizontal=0.6
9 9
 package.divider.vertical=0.8007380073800738
10 10
 package.editor.height=427
11 11
 package.editor.width=674
12
-package.editor.x=181
13
-package.editor.y=109
12
+package.editor.x=63
13
+package.editor.y=132
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0