Why the program only print the last book 4x

Assignment Help JAVA Programming
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]

Reference no: EM131590600

Questions Cloud

Discuss the e-commerce implementation plan : Update previously completed sections based on your instructor's feedback.
Find the duration of bond with settlement date : Find the duration of a bond with settlement date June 5, 2016, and maturity date December 3, 2025.
Complementary sequence for tyrosine only : Is this sequence DNA or RNA? How do you know? What is the complementary sequence for tyrosine only?
Discuss balancing safety and security with individual rights : Write an essay describing the importance of balancing safety and security with individual rights. Which do you think is most important
Why the program only print the last book 4x : why the program only print the last book 4X - Problem with line 08 - Problem with line 27
Originate on the scapula and fuse : How many muscles originate on the scapula and fuse to form one large tendon which is inserted into the humerus?
Developmental stages have on physical functioning : Recognize the influence that developmental stages have on physical, psychosocial, cultural,and spiritual functioning.
Andalusian variety of chicken : The so-called "blue" (really gray) Andalusian variety of chicken is produced by a cross between the black and white varieties.
Decisions of the united states supreme court : Write a paper explaining the issue, your proposed outcome, the social policy implications of your solution, and the research that supports your outcome

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd