Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BirthdayReminder {
  4.     public static void main(String[] args) {
  5.         String SENTINEL = "ZZZ";
  6.  
  7.         int counter = 0;
  8.  
  9.         String[] names = new String[10];
  10.         String[] dates = new String[10];
  11.  
  12.         Scanner keyboard = new Scanner(System.in);
  13.  
  14.         while (!keyboard.nextLine().equals(SENTINEL) || (counter == 10)){
  15.             for(String i : names ) {
  16.                 System.out.println("What is your friend name?");
  17.                 String temp_name = keyboard.nextLine();
  18.                 System.out.println("When he was birth?");
  19.                 String temp_date = keyboard.nextLine();
  20.                 dates[counter] = temp_date;
  21.                 names[counter] = temp_name;
  22.                 counter++;
  23.             }
  24.  
  25.         System.out.println("You have entered " + counter + "names. These are...");
  26.         for(String name : names ) {
  27.             System.out.print(name + " ");
  28.             }
  29.         }
  30.  
  31.         while (!keyboard.nextLine().equals(SENTINEL)){
  32.             System.out.println("Give me one of the name and I'll show you date. You can also type [ZZZ] to stop.");
  33.             String college_name = keyboard.nextLine();
  34.             for(String name : names) {
  35.                 if (college_name.equals(name)) {
  36.                     System.out.println(college_name + " date of birthday is " + dates[names.indexOf(college_name)]);
  37.                 }
  38.                 else {
  39.                     System.out.println("There's no such a person");
  40.                 }
  41.             }  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement