1234567891011121314151617181920212223242526272829303132
  1. /**
  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.
  6. */
  7. import java.util.*;
  8. public class Main {
  9. public static void main(String[] args ){
  10. Scanner keyboard = new Scanner(System.in);
  11. System.out.println("Please enter your name.");
  12. String name = keyboard.nextLine();
  13. String returnLine = "Hello, " + name + ".";
  14. if (name.equalsIgnoreCase("Alice")) {
  15. System.out.println(returnLine);
  16. } else if (name.equalsIgnoreCase("Bob")) {
  17. System.out.println(returnLine);
  18. } else {
  19. System.out.println("You aren't Alice or Bob!");
  20. }
  21. }
  22. }