I'm doing a library system which once I input a book name, and found inside the array, the out put would be "the book was returned" . But every time I input the name of one the books listed in the array, it still say that "the book is out of order". How can I solve this problem?
import java.util.Scanner;
public class NewClass {
public static void main (String args[]){
Scanner book = new Scanner(System.in);
String [] library = new String [4];
library [0] = "Brazil";
library [1] = "Japan";
library [2] = "China";
library [3] = "India";
String bookEntry = " ";
int day;
int x = 2;
int penalty;
for (int i = 0; i < library.length; i++){
System.out.println("Insert name of the book: ");
bookEntry= book.next();
if (bookEntry == library[i]){
System.out.println("The book was returned");
}else if (bookEntry != library[i]){
System.out.println("The book is out of order");
System.out.println("\n" + bookEntry.toUpperCase()+ " " + "is out since: ");
day = book.nextInt();
if (day > x){
penalty = day*20;
System.out.println("Total fine: " + penalty);
}else{
System.out.println("Not yet due.");
}
}
}
}
}