Spode

Name Database

Apr 6th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. public class Main {
  2.   public static void main(String[] args) {
  3.       Scanner input = new Scanner(System.in);
  4.  
  5.       System.out.print("Make Your Selection\n 1: Add A Name to the Database\n 2: List Names\n 3: Search for Names\n Your Selection: ");
  6.       int userSelect = input.nextInt();
  7.  
  8.       if (userSelect == 1) {
  9.         enterName();
  10.       }
  11.       else if (userSelect == 2) {
  12.         listNames(ArrayList<String>);
  13.       }
  14.     }
  15.  
  16.     public static void enterName() {
  17.       Scaner input = new Scanner(System.in);
  18.       System.out.print("Please enter a name now: ");
  19.       String nameInput = input.next();
  20.  
  21.       ArrayList<String> names = new ArrayList<String>();
  22.  
  23.       if (nameInput != " ") {
  24.         names.add(nameInput);
  25.       }
  26.       else {
  27.         System.out.println("Please enter a name!");
  28.       }
  29.     }
  30.  
  31.     public static void listNames(ArrayList<String> names) {
  32.       for (int i = 0; i < names.size(); i++) {
  33.         System.out.println(names);
  34.       }
  35.     }
  36. }
Add Comment
Please, Sign In to add comment