Pārlūkot izejas kodu

Wrote program to greet users named Alice or Bob

Connor Dunnigan 6 gadus atpakaļ
vecāks
revīzija
247c0e89d1
2 mainītis faili ar 14 papildinājumiem un 0 dzēšanām
  1. Binārs
      Main.class
  2. 14
    0
      Main.java

Binārs
Main.class Parādīt failu


+ 14
- 0
Main.java Parādīt failu

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