Name.java 532B

123456789101112131415161718192021222324
  1. /**
  2. * Write a description of class Name here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. import java.util.Scanner;
  8. public class Name
  9. {
  10. public void enterName(){
  11. Scanner s = new Scanner(System.in);
  12. System.out.println("What's your name?");
  13. String name = s.nextLine();
  14. if(name.equals("Bob") || name.equals("Alice")){
  15. System.out.println("What's up, " + name + "!");
  16. } else {
  17. System.out.println("Please leave");
  18. }
  19. }
  20. }