Question
Can anyone tell me what's wrong with this code for java? package birthdayreminder; import java.util.Scanner; public class BirthdayReminder { /** * @param args the command
Can anyone tell me what's wrong with this code for java?
package birthdayreminder; import java.util.Scanner;
public class BirthdayReminder {
/** * @param args the command line arguments */ public static void main(String[] args) { String sentinel ="ZZZ"; final int size = 10; int count = 0; String name = null; String dateofBirth = null; String[] names = new String[size]; String[] birthdates = new String[size]; Scanner inputDevice = new Scanner(System.in); System.out.println("Please enter name. (enter ZZZ to exit) "); name = inputDevice.nextLine(); while(!name.equals(sentinel) && count < 10) { System.out.println("Please enter data of birth in mm/dd/yyyy format. "); dateofBirth = inputDevice.nextLine(); names[count] = name; birthdates[count]= dateofBirth; System.out.println("Please enter next name. (enter ZZZ to exit) "); name = inputDevice.nextLine(); count++; } System.out.println("The total number number of names entered is. " +count ); boolean repeat = true; boolean found = false; while(repeat) { System.out.println("Enter name to display birthday of that person. (enter ZZZ to exit)"); name = inputDevice.nextLine(); if(name.equals(sentinel)) repeat = false; else { for(int loop = 0; loop < count &&!found; loop++) if(names[loop].equals(name)) found = true; dateofBirth = birthdates[loop]; } } if(found) System.out.println("Date of birth of " + name + "is" + dateofBirth); else System.out.println("That Persons name" + name + "is not found please enter the correct name" ); } found = false; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started