Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

How does the writer establish credibility?

Answered: 1 week ago

Question

4. What should Bob and jim do now to resolve this conflict?

Answered: 1 week ago

Question

=+ b. How would the change you describe in part

Answered: 1 week ago

Question

=+ 6. A Case Study in this chapter concludes that if

Answered: 1 week ago