Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

=+Is it possible to operate union-free?

Answered: 1 week ago

Question

=+impact member states and MNEs?

Answered: 1 week ago