Przeglądaj źródła

Wrote program to greet users named Alice or Bob

Connor Dunnigan 6 lat temu
rodzic
commit
247c0e89d1
2 zmienionych plików z 14 dodań i 0 usunięć
  1. BIN
      Main.class
  2. 14
    0
      Main.java

BIN
Main.class Wyświetl plik


+ 14
- 0
Main.java Wyświetl plik

@@ -1,9 +1,23 @@
1 1
 /**
2 2
  * Created by iyasuwatts on 10/17/17.
3 3
  */
4
+import java.util.Scanner;
5
+
4 6
 public class Main {
5 7
 
6 8
     public static void main(String[] args ){
7 9
 
10
+      Scanner stdin = new Scanner(System.in);
11
+
12
+      System.out.println("Please enter your username: ");
13
+      String userName;
14
+      userName = stdin.nextLine();
15
+
16
+      String tempName = userName.toUpperCase();
17
+      if(tempName.equals("ALICE") || tempName.equals("BOB")){
18
+        System.out.println("Greetings " + userName);
19
+      } else{
20
+        System.out.println("Username is not Alice or Bob... no greeting for you");
21
+      }
8 22
     }
9 23
 }