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

  Calculates the minimum maximum and average for each quiz

Write a Java application that calculates the minimum, maximum, and average for each quiz. Print the output results in a table format using a text area. Use loop and if statement control structures as well as Array data structure

  Write a program that computes the average salary

The first programming project involves writing a program that computes the average salary for a collection of employees of different types. This program consists of four classes. The first class is the Employee class, which contains the employee's..

  Construct a huffman code tree

Draw the tree that would be formed by inserting the words in this question into a binary search tree and construct a Huffman code tree. Show the initial priority queue and all changes in its state as the tree is constructed.

  Write a method public static char touppercase(char ch)

Your main method should contain three calls to changeCase() for each case mentioned above.

  Flowchart create a flowchart that prompts

Flowchart Create a flowchart that prompts and gets input for the current grade. If the grade is 90 or above print "A". If the grade is 80-89 then print "B". If the grade is 70-79 then print "C".

  What is the purpose of the restrict keyword in c99

Arrays of strings in C and C++ can also be initialized with string literals. In this case, the array is one of pointers to characters.

  Write a java applet for grade of gas in costco gas station

Write a java applet (not a java application program) for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use.

  Calculate the total value of property for sale

Prompt the user for the name of the input file (listings.txt). Open the listings.txt file and read in property listing information using a buffered FileReader. Calculate the total value of property for sale.

  Write a java program consisting of pigdriver and pig

You will write a Java program consisting of PigDriver and Pig.java, that must Display a welcome message, "Let's Play Pig", Display a blank line and Prompt for the name of the human player.

  File integrity checker - tripwire

Write a program that will perform some of the basic tasks accomplished by a file integrity checker such as Tripwire.

  Create screen with one spinner containing at least two city

Create a screen with one spinner containing at least two cities. On selection of the city in the spinner, make a service call to the weather API that returns the results in XML format.

  Compute the correct number of square feet needed

The Carpet House owner wants to put a carpet calculator on his website so that visitors can estimate the amount of carpet they will need to purchase.

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