Bläddra i källkod

these are my changes

Steffon Williams 6 år sedan
förälder
incheckning
ab14441d82
4 ändrade filer med 36 tillägg och 9 borttagningar
  1. Binär
      AliceAndBob.class
  2. 7
    0
      AliceAndBob.ctxt
  3. 29
    0
      AliceAndBob.java
  4. 0
    9
      Main.java

Binär
AliceAndBob.class Visa fil


+ 7
- 0
AliceAndBob.ctxt Visa fil

@@ -0,0 +1,7 @@
1
+#BlueJ class context
2
+comment0.target=AliceAndBob
3
+comment0.text=\n\ This\ program\ will\ do\ the\ following\:\n\ Firstly\ ask\ the\ user\ to\ input\ his/her\ name.\ Then\ find\ a\ way\ to\ check\ the\ person's\ name\ to\ see\ if\ it\ is\ Bob\ or\ Alice.\ \n\ If\ the\ user's\ name\ is\ either\ Alice\ or\ Bob;\ then\ a\ greeting\ will\ be\ printed\ to\ the\ screen.\ \n
4
+comment1.params=args
5
+comment1.target=void\ main(java.lang.String[])
6
+comment1.text=\ The\ Scanner\ class\ is\ used\ as\ a\ simple\ text\ scanner\ which\ can\ parse/analyze\ a\ sentence\ in\ parts.\ \n\ In\ this\ case\ Scanner\ is\ used\ to\ scan\ the\ user's\ input\ to\ check\ for\ something\ specific.\ \nSystem.out.print\ ("What\ is\ your\ name?");\ --->\ this\ prints\ "What\ is\ your\ name?"\ to\ the\ console\ and\ this\ prompts\ the\ user\ to\ input\ his/her\ name.\ \n\ String\ name\ \=\ in.nextLine--->\ this\ will\ print\ the\ entire\ line\ that\ that\ the\ user\ enters.\ \n
7
+numComments=2

+ 29
- 0
AliceAndBob.java Visa fil

@@ -0,0 +1,29 @@
1
+
2
+import java.util.*;
3
+/**
4
+ * This program will do the following:
5
+ * Firstly ask the user to input his/her name. Then find a way to check the person's name to see if it is Bob or Alice. 
6
+ * If the user's name is either Alice or Bob; then a greeting will be printed to the screen. 
7
+ */
8
+public class AliceAndBob {
9
+    /* The Scanner class is used as a simple text scanner which can parse/analyze a sentence in parts. 
10
+     * In this case Scanner is used to scan the user's input to check for something specific. 
11
+     *System.out.print ("What is your name?"); ---> this prints "What is your name?" to the console and this prompts the user to input his/her name. 
12
+     * String name = in.nextLine---> this will print the entire line that that the user enters. 
13
+     */
14
+    public static void main(String[] args ){
15
+        Scanner in = new Scanner(System.in);
16
+
17
+        System.out.print("What is your name?");
18
+        String name = in.nextLine(); 
19
+        
20
+        //If the user's name is equivalent to Alice or Bob; then print "Hi!"
21
+        
22
+        if(name.equals("Alice") || name.equals("Bob")){
23
+            System.out.println("Hi!");
24
+        
25
+        }
26
+
27
+    }
28
+    
29
+}

+ 0
- 9
Main.java Visa fil

@@ -1,9 +0,0 @@
1
-/**
2
- * Created by iyasuwatts on 10/17/17.
3
- */
4
-public class Main {
5
-
6
-    public static void main(String[] args ){
7
-
8
-    }
9
-}