Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BirthdayReminder {
- public static void main(String[] args) {
- String SENTINEL = "ZZZ";
- int counter = 0;
- String[] names = new String[10];
- String[] dates = new String[10];
- Scanner keyboard = new Scanner(System.in);
- while (!keyboard.nextLine().equals(SENTINEL) || (counter == 10)){
- for(String i : names ) {
- System.out.println("What is your friend name?");
- String temp_name = keyboard.nextLine();
- System.out.println("When he was birth?");
- String temp_date = keyboard.nextLine();
- dates[counter] = temp_date;
- names[counter] = temp_name;
- counter++;
- }
- System.out.println("You have entered " + counter + "names. These are...");
- for(String name : names ) {
- System.out.print(name + " ");
- }
- }
- while (!keyboard.nextLine().equals(SENTINEL)){
- System.out.println("Give me one of the name and I'll show you date. You can also type [ZZZ] to stop.");
- String college_name = keyboard.nextLine();
- for(String name : names) {
- if (college_name.equals(name)) {
- System.out.println(college_name + " date of birthday is " + dates[names.indexOf(college_name)]);
- }
- else {
- System.out.println("There's no such a person");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement