In: Computer Science
Please I can get a flowchart and a pseudocode for this java code. Thank you
//import the required classes
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BirthdayReminder {
public static void main(String[] args) throws
IOException {
// declare the required
variables
String sName = null;
String names[] = new String[10];
String birthDates[] = new String[10];
int count = 0;
boolean flag = false;
// to read values from the console
BufferedReader dataIn = new BufferedReader(new
InputStreamReader(
System.in));
// loop till the user enters 10 names or user enters ZZZ
for (int i = 0; i < 10; i++)
{
// prompt the user to enter the name
System.out.print("Enter person's name: ");
sName = dataIn.readLine();
// check the condition whether the user enters ZZZ if so break the
loop
if (sName.equalsIgnoreCase("ZZZ"))
break;
// else assign the value to the names array
names[i] = sName;
// prompt the user to enter the date of birth
System.out.print("Enter Date of Birth as(mm/dd/yyyy): ");
birthDates[i] = dataIn.readLine();
count = count + 1;
}
// print the count value
System.out.println("The count of names is:" + count);
// print the list of names
System.out.println("The list of names:");
for (int i = 0; i < count; i++)
{
System.out.println(names[i]);
}
// loop till the user enters ZZZ
do
{
// prompt the user to enter the name
System.out.println("Enter a name: ");
sName = dataIn.readLine();
// check the condition for the user entered ZZZ if so break the
loop
if (sName.equalsIgnoreCase("ZZZ"))
break;
// else search the name and display the respective date of
birth
for (int i = 0; i < count; i++)
{
if (sName.equalsIgnoreCase(names[i]))
{
System.out.println(sName + "'s birthday is on "
+ birthDates[i]);
flag = true;
break;
}
}
// if the flag value is false then display the error message
if (flag == false)
System.out.println("The persons name is not in the list");
} while (true);
}
}
as you have mentioned you needed a flowchart in the question
please follow the link for the flow chart
thank you.