Reference no: EM131590600
01 /*********************** Book.java ***********************/
02 package buggydemo1
03
04 public class Book {
05 String title;
06 String author;
07 int year;
08 double p;
09
10 String output() {
11 String retval;
12 retval = title + " by " + author + " (" + year + "), tiny_mce_markerquot; p;
13 return retval;
14 }
15
16 }
17
18 /******************** BuggyDemo1.java ********************/
19 package buggydemo1
20
21 import java.util.ArrayList;
22 import java.util.Scanner; 23
24 public class BuggyDemo1 {
25
26 public static void main(String[] args) {
27 ArrayList<String> books = new ArrayList<>();
28 Book b = new Book();
29 Scanner keyboard = new Scanner(System.in);
30 String userinput; 31
32 String moreBooks;
33 do {
34 System.out.println("Enter Book Info");
35 System.out.println("Title: ");
36 b.title = keyboard.nextLine();
37 System.out.println("Author: ");
38 b.title = keyboard.nextLine();
39 System.out.println("Year: ");
40 userinput = keyboard.nextLine();
41 b.year = Integer.parseInt(userinput);
42 System.out.println("Price: ");
43 userinput = keyboard.nextLine();
44 b.p = Integer.parseInt(userinput);
45 books.add(b);
46 System.out.println();
47 System.out.println("Enter more? (Y/N) ");
48 moreBooks = keyboard.nextLine();
49 } while (moreBooks == ("Y"));
50
51 for (Book element : books) {
52 System.out.println(b.output());
53 }
54 }
55 }
Problem with line 08 [double is correct]: ________________________
Problem with line 12: ____________________________________________
Problem with line 27: ____________________________________________
Problem with line 30: ____________________________________________
Problem with line 38: ____________________________________________
Problem with line 44: ____________________________________________
Problem with line 49: ____________________________________________
Problem with line 52: ____________________________________________
If 4 books are entered, why the program only print the last book 4X?
[there are two reasons]