New Posts  All Forums:Forum Nav:

Need help with Java

post #1 of 2
Thread Starter 
I am currently enrolled in a Java Programming course. I'm having some trouble with an assignment my professor gave me, and she is on a vacation with her family so I am unable to get her input on my trouble. I was asked to take a method that I use to search for the title of a book, and display all books with that title. It must not output all books with the title AND author I inputed.

I included the method below. I am not looking for anyone to give me the answer, but some help in the right direction would definitely help, and be appreciated. Thanks!

public static void titleSearch(Book[] bookInventory){
Scanner input = new Scanner(System.in);

String t;
String message = " ";

System.out.print([COLOR="rgb(46, 139, 87)"]"Enter title: "[/COLOR]);
t = input.nextLine();//nextLine is used to allow string concantination.

for (int i = 1; i < Book.getNumberOfBooks(); i++){

if (t == null ? bookInventory[i].getTitle() == null : t.equalsIgnoreCase(bookInventory[i].getTitle())){
message = message + bookInventory[i].toString();
} // end if
} // end for loop

System.out.println("\
Here are the books you searched for:\
"
+message);


}//end titleSearch method
My 1st Build
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD 5600+ @ 2.8GHz ASUS Crosshair eVGA 8800GTS 640MB Corsair XMS2 DDR2 800 4GB(2X2GB) Cas 5 
Hard DriveOptical DriveOSMonitor
160GB OS Drive + 500GB x4 = 1.5TB RAID 5 Lite-On SATA Burner Windows Vista Ultimate (64-Bit) Dual 20" Dell Widescreen's 
KeyboardPowerCaseMouse
Saitek Eclipse Antec Earthwatts 500W Thermaltake Armor Logitech MX518 
Mouse Pad
None 
  hide details  
Reply
My 1st Build
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD 5600+ @ 2.8GHz ASUS Crosshair eVGA 8800GTS 640MB Corsair XMS2 DDR2 800 4GB(2X2GB) Cas 5 
Hard DriveOptical DriveOSMonitor
160GB OS Drive + 500GB x4 = 1.5TB RAID 5 Lite-On SATA Burner Windows Vista Ultimate (64-Bit) Dual 20" Dell Widescreen's 
KeyboardPowerCaseMouse
Saitek Eclipse Antec Earthwatts 500W Thermaltake Armor Logitech MX518 
Mouse Pad
None 
  hide details  
Reply
post #2 of 2
Thread Starter 
Nvm figured it out. Thread can be closed.
My 1st Build
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD 5600+ @ 2.8GHz ASUS Crosshair eVGA 8800GTS 640MB Corsair XMS2 DDR2 800 4GB(2X2GB) Cas 5 
Hard DriveOptical DriveOSMonitor
160GB OS Drive + 500GB x4 = 1.5TB RAID 5 Lite-On SATA Burner Windows Vista Ultimate (64-Bit) Dual 20" Dell Widescreen's 
KeyboardPowerCaseMouse
Saitek Eclipse Antec Earthwatts 500W Thermaltake Armor Logitech MX518 
Mouse Pad
None 
  hide details  
Reply
My 1st Build
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD 5600+ @ 2.8GHz ASUS Crosshair eVGA 8800GTS 640MB Corsair XMS2 DDR2 800 4GB(2X2GB) Cas 5 
Hard DriveOptical DriveOSMonitor
160GB OS Drive + 500GB x4 = 1.5TB RAID 5 Lite-On SATA Burner Windows Vista Ultimate (64-Bit) Dual 20" Dell Widescreen's 
KeyboardPowerCaseMouse
Saitek Eclipse Antec Earthwatts 500W Thermaltake Armor Logitech MX518 
Mouse Pad
None 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming