Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 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.

I am struggling with the above portion of my assignment. In the code below I will hightlight the portion where i attempted to complete what is asked above.

public class StateInfo { public static void main(String[] args) { String arr[][]=new String[6][3]; arr[0][0]="Maryland";arr[0][1]="Baltimore oriole";arr[0][2]="Black-eyed susan"; arr[1][0]="Maine";arr[1][1]="Chickadee";arr[1][2]="White Pine Cone"; arr[2][0]="New Hampshire";arr[2][1]="Purple Finch";arr[2][2]="Purple Lilac"; arr[3][0]="Vermont";arr[3][1]="Hermit Thrush";arr[3][2]="Red Clover"; arr[4][0]="Massachusetts";arr[4][1]="Black-capped Chickadee";arr[4][2]="Mayflower"; arr[5][0]="Connecticut";arr[5][1]="American Robin";arr[5][2]="Mountain Laurel"; Scanner input=new Scanner(System.in); int i; while(true) { System.out.print("Enter name of state or None to exit: "); String state=input.nextLine(); if(state.equalsIgnoreCase("none")) if (stateInfo.trim().equalsIgnoreCase("None")) { System.out.println("**** Thank you ***** A summary report for each State, Bird, and Flower is:"); //Iterating searchedState array to get each search reasult for (int x = 0; x < new String.length; x++) { if (newString[x] != null) { System.out.println(newString[x]); } } System.out.println("Please visit our site again!"); break;//breaking the mail while loop to exit }

break; state=state.trim(); for(i=0;i break; } } if(i==arr.length) { System.out.println("State is not relevant");

}

}

} }

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions