瀏覽代碼

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

Elliott Stansbury 6 年之前
父節點
當前提交
50a61d348d
共有 2 個檔案被更改,包括 15 行新增4 行删除
  1. 13
    2
      Main.java
  2. 2
    2
      package.bluej

+ 13
- 2
Main.java 查看文件

@@ -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 查看文件

@@ -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