#34 Main.java

Aperto
jtinkler vorrebbe unire 1 commit da jtinkler/ZCW-AliceAndBob-BlueJ:master a master
3 ha cambiato i file con 29 aggiunte e 3 eliminazioni
  1. BIN
      Main.class
  2. 5
    0
      Main.ctxt
  3. 24
    3
      Main.java

BIN
Main.class Vedi File


+ 5
- 0
Main.ctxt Vedi File

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

+ 24
- 3
Main.java Vedi File

@@ -1,9 +1,30 @@
1 1
 /**
2 2
  * Created by iyasuwatts on 10/17/17.
3 3
  */
4
-public class Main {
5 4
 
6
-    public static void main(String[] args ){
5
+   import java.util.Scanner;
6
+   
7
+public class Main {
7 8
 
9
+    public static void main(String[] args ){ 
10
+        /*intialize scanner*/
11
+        Scanner scanner = new Scanner(System.in);
12
+        
13
+        System.out.print("What is your name?");
14
+        
15
+        String name = scanner.nextLine();
16
+        
17
+        if (name.equals("Alice")) {
18
+            System.out.println("Hey Alice ");
19
+        } else if (name.equals("Bob")) {
20
+            System.out.println("Hello Bob!");
21
+        
22
+        } else { System.out.println("Unexpected User");
23
+            
24
+        }
25
+         
26
+        
27
+     }
8 28
     }
9
-}
29
+    
30
+