Question
1.what is the error of this java ?I am unable to print? import java.util.Scanner; public class TestBirdFlower { public static void main(String[] args) { BirdFlower
1.what is the error of this java ?I am unable to print?
import java.util.Scanner;
public class TestBirdFlower { public static void main(String[] args) { BirdFlower inform = new BirdFlower(); String stateName[][] = inform.getState(); String searchedState[] = new String[stateName.length];//Array to store search reasult // Initialize scanner Scanner userInput = new Scanner(System.in); int searchCount = 0; while (true) { // Prompt user and scan user input System.out.println("Enter a state name to see its bird and flower. Enter 'None' to exit the application."); String stateInfo = userInput.nextLine(); // To ignore cap sensitivity and leading/trailing white spaces if (stateInfo.trim().equalsIgnoreCase("None")) { System.out.println("**** Thank you ***** A summary report for each State, Bird, and Flower is:"); //IteratingsearchedState array to get each search reasult for (int x = 0; x < searchedState.length; x++) { if (searchedState[x] != null) { System.out.println(searchedState[x]); } } System.out.println("Please visit our site again!"); break;//breaking the mail while loop to exit } else { int index = getStateIndex(stateInfo, stateName); if (index != -1) { System.out.println("Bird: " + getBird(index, stateName)); System.out.println("Flower: " + getFlower(index, stateName)); //Storing search reasult searchedState[searchCount] = stateInfo +", " + getBird(index, stateName) + ", " + getFlower(index, stateName); searchCount++;//increament vlid serach count } else { System.out.println("Please input a valid state name."); } } } } private static int getStateIndex(String stateInfo, String[][] stateName) { for (int x = 0; x < stateName.length; x++) { if (stateInfo.trim().equalsIgnoreCase(stateName[x][0])) { return x; } } return -1; } private static String getBird(int index, String[][] stateName) { return stateName[index][1]; } private static String getFlower(int index, String[][] stateName) { return stateName[index][2]; }
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