浏览代码

Added program to greet Alice and Bob

Trinh Tong 6 年前
父节点
当前提交
39f4fdfe73
共有 4 个文件被更改,包括 34 次插入7 次删除
  1. 二进制
      Main.class
  2. 5
    0
      Main.ctxt
  3. 25
    3
      Main.java
  4. 4
    4
      package.bluej

二进制
Main.class 查看文件


+ 5
- 0
Main.ctxt 查看文件

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

+ 25
- 3
Main.java 查看文件

@@ -1,9 +1,31 @@
1 1
 /**
2
- * Created by iyasuwatts on 10/17/17.
2
+ * Trinh Tong
3
+ * Lab - Alice and Bob
4
+ * Using the scanner to take an input and then display the message 
5
+ * with the user's keyboard input.
3 6
  */
7
+import java.util.*; 
8
+
4 9
 public class Main {
5 10
 
6 11
     public static void main(String[] args ){
7
-
8
-    }
12
+        
13
+        Scanner keyboard = new Scanner(System.in);
14
+        
15
+        System.out.println("Please enter your name.");
16
+        
17
+        String name = keyboard.nextLine();
18
+        
19
+        String returnLine = "Hello, " + name + ".";
20
+        
21
+        if (name.equalsIgnoreCase("Alice")) {
22
+            System.out.println(returnLine); 
23
+        } else if (name.equalsIgnoreCase("Bob")) {
24
+            System.out.println(returnLine); 
25
+        } else {
26
+            System.out.println("You aren't Alice or Bob!"); 
27
+        }
28
+    }  
29
+        
9 30
 }
31
+

+ 4
- 4
package.bluej 查看文件

@@ -1,8 +1,8 @@
1 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
2
+editor.fx.0.height=722
3
+editor.fx.0.width=800
4
+editor.fx.0.x=512
5
+editor.fx.0.y=164
6 6
 objectbench.height=101
7 7
 objectbench.width=776
8 8
 package.divider.horizontal=0.6