The scanner works up until I get to the the part where I ask the user if they have read the book. When I type in yes or no it automatically just goes to the else case. Then when I try to see what the input was after I type in yes or no it prints out blank.
import java.util.Scanner;
public class YourBooks {
public static void main (String [] args){
String title,author,publisher,rating,dateS,dateF,dateP,ans;
int isbn,pages;
Scanner keyboard=new Scanner(System.in);
System.out.println("What is the title?");
title=keyboard.nextLine();
keyboard.nextLine();
System.out.println("Who is the author?");
author=keyboard.nextLine();
System.out.println("How many pages does the book have?");
pages=keyboard.nextInt();
System.out.println("Who is the publisher?");
publisher=keyboard.nextLine();
keyboard.nextLine();
System.out.println("What is the Isbn?");
isbn=keyboard.nextInt();
System.out.println("Have your read the book?");
ans=keyboard.nextLine();
keyboard.nextLine();
if (ans.equalsIgnoreCase("yes")){
System.out.println("When did you start reading the book?");
dateS=keyboard.nextLine();
System.out.println("When did you finish reading the book?");
dateF=keyboard.nextLine();
System.out.println("How would you rate the book?");
rating=keyboard.nextLine();
}
else if (ans.equalsIgnoreCase("no")){
System.out.println("When do you plan to read the book?");
dateP=keyboard.nextLine();
}
else{
System.out.println("I do not understand what you are trying to say.\nEnd of program");
System.exit(0);
}
}
}