In: Computer Science
Please can I kindly get a flowchart 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);
}
}
Answer-
Flowchart for the following Java code-
=======================Flow Chart===================
There are four classes in this Flowchart-
There are three images you need to combine all images.
Note- Please do upvote, if any problem then comment in
box sure I will help.