need help with if statement actions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KRXB
    New Member
    • May 2010
    • 2

    need help with if statement actions

    hello,

    im working on a program that simulates a library, in this library there are 4 classes: llibrary, book, patron, and libraryMain.

    In libraryMain, i'm using if statements to allow the user to input text into the menu, choosing different options. When i run the program, it runs through the if statements in order, so i cant enter something like "show patrons" without it executing the "invalid entry" string from the previous case.

    i would like the to allow input for every set of cases at the same time without going in order.

    Code:
    String input;
    		
    		System.out.print("Enter a selection: ");
    		
    		input = in.nextLine();
    
    		// add/remove books control
    		if (input.equalsIgnoreCase("add a book"))
    		{
    			System.out.println("Enter book to add: ");	
    		}		
    		else if (input.equalsIgnoreCase("remove book"))
    		{	
    			System.out.println("Enter book to remove: ");
    		}
    		else
    		{
    			System.out.println("Invalid Entry");
    		}
    		
    		System.out.print("Enter a selection: ");
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    I can not see any patron object created in the code. Is it the complete code?

    Regards
    Dheeraj Joshi

    Comment

    • KRXB
      New Member
      • May 2010
      • 2

      #3
      oh, my apologies. i attached all 4 classes, i don't have a lot done on them yet, but thats why im looking for guidance.

      thanks Dheeraj Joshi
      Attached Files

      Comment

      Working...