I need to add a “summary report” function to this code
I need to add a “summary report” function to this code.<br/>”<br/> Hint:
Store the State information in a multidimensional array. The program should continue to prompt the user to enter a state until “None” is entered. After all States have been entered by the user, the program should display a summary of the results. You will need to do some research to find the State birds and flowers.
Here is a sample run:
Enter a State or None to exit: Maryland Bird: Baltimore Oriole Flower: Black-eyed Susan Enter a State or None to exit: Delaware Bird: Blue Hen Chicken Flower: Peach Blossom Enter a State or None to exit: None
**** Thank you *****
A summary report for each State, Bird, and Flower is: Maryland, Baltimore Oriole, Black-eyed Susan Delaware, Blue Hen Chicken, Peach Blossom Please visit our site again!
”
import java.util.Scanner;
public class StatesDataEntry {
/**
* the command line arguments
*/
public static int getInfo(String statesDataEntry[][],String state)
{
int position = -1;
boolean found = false;
for (int index=0; index<statesDataEntry.length && !found; index++)
{
if(statesDataEntry[index][0].equalsIgnoreCase(state))
position=index;
}
return position;
}
public static void main(String[] args) {
// TODO code application logic here
Scanner userInput = new Scanner(System.in);
//Prompt use to enter a state
String[][] stateData = new String[][] {
{“Alabama”, “Yellowhammer”, “Camelia”},
{“Alaska”, “Willow Ptarmigan”, “Forget-Me-Not”},
{“Arizona”, “Cactus Wren”, “Saguaro Cactus Blossom”},
{“Arkansas”, “Mockingbird”, “Apple Blossom”},
{“California”, “California Valley Quail”, “Golden Poppy”},
{“Colorado”, “Lark Bunting”, “Rocky Mountain Columbine”},
{“Connecticut”, “Robin”, “Mountain Laurel”},
{“Delaware”, “Blue Hen Chicken”, “Peach Blossom”},
{“Florida”, “Mockingbird”, “Orange Blossom”},
{“Georgia”, “Brown Thrasher”, “Cherokee Rose”},
};
while(true) {
System.out.println( );
System.out.println(“Enter a State or None to exit:”);
String stateName = userInput.next();
if(stateName.equalsIgnoreCase(“None”)) {
System.exit(0);
}
else {
int position = getInfo(stateData, stateName);
if(position != -1) {
System.out.println(“Bird: ” + stateData[position][1]);
System.out.println(“Flower: ” + stateData[position][2]);
System.out.println( );
}
// End while loop
else {
System.out.println(“Invalid State Data Entered”);
}
}
}
}
}