浏览代码

Alice/Bob lab

Nuridalia Hermandez 6 年前
父节点
当前提交
f442240488
共有 4 个文件被更改,包括 27 次插入4 次删除
  1. 二进制
      Main.class
  2. 5
    0
      Main.ctxt
  3. 18
    0
      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

+ 18
- 0
Main.java 查看文件

@@ -1,9 +1,27 @@
1 1
 /**
2 2
  * Created by iyasuwatts on 10/17/17.
3 3
  */
4
+import java.util.Scanner;
4 5
 public class Main {
5 6
 
6 7
     public static void main(String[] args ){
8
+        Scanner input = new Scanner(System.in);
9
+        //prompt the user to enter name
10
+        System.out.println(" Please Enter your Name:");
7 11
 
12
+        String name;
13
+        name=input.next();
14
+        // if statement to output a greatting to Allice 
15
+        if ( name.equals("Alice")){
16
+            System.out.println("Welcome" + name +" to the world of Java" );
17
+        }
18
+
19
+        // gretting stament for Bob
20
+        else if (name.equals("Bob")) {
21
+            System.out.println("welcome" + name+ "to the world of Java");}
22
+// if the name is not Alice or Bob
23
+            else {
24
+                System.out.println("Sorry, you dont belong here!");
25
+            }
8 26
     }
9 27
 }

+ 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=313
5
+editor.fx.0.y=24
6 6
 objectbench.height=101
7 7
 objectbench.width=776
8 8
 package.divider.horizontal=0.6