i want to print my availaiblebooksbooks array. I am doing this using for loop.
initial output
welcome..., what do you want to do in library
choose any one performable action
1.addbook
2.purchasbook
3.returnbook
4.showavilaiblebook
I am putting user input 4.showavilaiblebook
after putting input is m getting this.
action not found
action not found
action not found
where it should print:-
Think and grow rich
how to influence pepoles
Richest man in bablyon
Jeet ya har
great words win heart
Time management
positive thinking
power thinking
subconcious mind
My java code
public class OnlineLibrary {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("welcome..., what do you want to do in library");
String [] actionlist = {"choose any one performable action", "1.addbook","2.purchasbook","3.returnbook","4.showavilaiblebook"};
for(int i = 0; i<actionlist.length; i++) {System.out.println(actionlist[i]); }
//list of library books
String [] availaiblebooksbooks = {"Think and grow rich", "how to influence pepoles", "Richest man in bablyon", "Jeet ya har", "great words win heart","Time management", "positive thinking", "power thinking","subconcious mind"};
String input = scan.next();
for(int i = 1; i<actionlist.length; i++) {
String actionno = actionlist[i];
if (input.equals(actionno)) { }
else if (input.equals(actionno)) { }
else if (input.equals(actionno)) { }
else if (input.equals(actionno)) { for(int p = 0; p<availaiblebooksbooks.length; p++) { System.out.println(availaiblebooksbooks[p]); }}
else {System.out.println("action not found");}
}
}
}
The expected answer is obtained by keeping its direct value of the arrayitem. But I want to know what is the problem with this.