vendredi 25 avril 2014

Java print two lines together


Vote count:

0




I'm trying to print a message on the screen and after that, take a value from the keyboard. i have 4 prints in a row but i have scan methods between them. When i run my code, the first two prints run together and i can't insert a value at the first variable, after the first print.



case 1:
System.out.println("###Book Data###");
System.out.print("Name of the book:\t");
String Name = key.nextLine();

System.out.print("ISBN of the book:\t");
String ISBN = key.nextLine();

System.out.print("Author of the book:\t");
String author = key.nextLine();

System.out.print("Copies of the book:\t");
int copies = key.nextInt();
book Book = new book(ISBN,Name,author,copies);
lib.AddBook(Book);
break;


#########Text Printed######
Please enter your selection: 1
###Book Data###
Name of the book: ISBN of the book:


Thanks in advance for your help!



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire