Question: I am trying to add to a new object called bk but my program does not read the users input after he uses a space

I am trying to add to a new object called bk but my program does not read the users input after he uses a space bar.

//Book Class package com.codewithEmmanuel; public class book { private int identificationNumber; private String title;String itemAvailable; private int no_of_available_copies; private String author; public book(int identificationNumber, String title, String itemAvailable, int no_of_available_copies, String author){ this.identificationNumber = identificationNumber; this.title = title; this.itemAvailable = itemAvailable; this.no_of_available_copies = no_of_available_copies; this.author = author; } public void setIdentificationNumber(int identificationNumber) { this.identificationNumber = identificationNumber; } public int getIdentificationNumber() { return identificationNumber; } public void setTitle(String title) { this.title = title; } public String getTitle() { return title; } public void setItemAvailable(String itemAvailable) { this.itemAvailable = itemAvailable; } public String getItemAvailable() { if (no_of_available_copies <= 0) { itemAvailable = "Not Available"; } else { itemAvailable = "Available"; } return itemAvailable; } public void setNo_of_available_copies(int no_of_available_copies) { this.no_of_available_copies = no_of_available_copies; } public int getNo_of_available_copies() { return no_of_available_copies; } public void setAuthor(String author) { this.author = author; } public String getAuthor() { return author; } @Override public String toString() { return "Identification Number:" + getIdentificationNumber() + ", Title:" + getTitle() + ", Item:"+getItemAvailable()+ ", No_of_available_copies:" + getNo_of_available_copies()+ ", Author:"+getAuthor(); } }
//Main class package com.codewithEmmanuel; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); ArrayList bk = new ArrayList(); System.out.println("Enter: Identification Number, Title, Item Available, Number of copies, Author"); //This is where I run into issues. Computer does not read inputs when the user uses the space bar bk.add(new book(input.nextInt(), input.next(), input.next(), input.nextInt(), input.next())); System.out.println(bk); } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!