Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are starting a book club with some friends, and each of you is submitting fi

ID: 3782530 • Letter: Y

Question

You are starting a book club with some friends, and each of you is submitting five books as possible reading choices. Write, compile, and test a Java program that displays your list on the console. (See figure below). The first two lines display a heading, such as the blowing: The next five lines will display your choices. Align the list items with the heading. Just hard code in your book choices. This is designed to get you comfortable with the IDE, using System out.printin. compiling and running a program in JAVA.

Explanation / Answer

BookClub.java

public class BookClub {
  
   //Declaring instance variables
   private String bookTitle;
   private String author;
   private String date;
  
   //Parameterized constructor
   public BookClub(String bookTitle, String author, String date) {
       super();
       this.bookTitle = bookTitle;
       this.author = author;
       this.date = date;
   }
  
   //Getters and Setters
   public String getBookTitle() {
       return bookTitle;
   }
   public void setBookTitle(String bookTitle) {
       this.bookTitle = bookTitle;
   }
   public String getAuthor() {
       return author;
   }
   public void setAuthor(String author) {
       this.author = author;
   }
   public String getDate() {
       return date;
   }
   public void setDate(String date) {
       this.date = date;
   }

  

}

______________________

Test.java

import java.util.ArrayList;

public class Test {


   public static void main(String[] args) {
       //Creating an ArrayList
       ArrayList<BookClub> ar=new ArrayList<BookClub>();
      
       //Creating BookClub objects
       BookClub bc1=new BookClub("Glad News of the natural World","T.R.Pearson","7/04/2007");
       BookClub bc2=new BookClub("Deep in the Green","Anne Raver","6/30/1995");
       BookClub bc3=new BookClub("Access 2007:The Missing Manual","Mathew MacDonald","12/01/2006");
       BookClub bc4=new BookClub("I Remember Nothing","Nora Ephran","11/15/2010");
       BookClub bc5=new BookClub("Purple Jesus","Ron Cooper","9/15/2010");
      
      
       //Adding BookClub Objects to the ArrayList
       ar.add(bc1);
       ar.add(bc2);
       ar.add(bc3);
       ar.add(bc4);
       ar.add(bc5);
      
      
       //Displaying the output
       System.out.println("Book Title Author Date");
       System.out.println("-------------------------------------------------------------");
       for(BookClub bc:ar)
       {
           System.out.printf("%-35s %-25s %-15s %n",bc.getBookTitle(),bc.getAuthor(),bc.getDate());
       }
   }

}

_________________________

Output:

Book Title               Author               Date
-------------------------------------------------------------
Glad News of the natural World T.R.Pearson 7/04/2007   
Deep in the Green Anne Raver 6/30/1995   
Access 2007:The Missing Manual Mathew MacDonald 12/01/2006
I Remember Nothing Nora Ephran 11/15/2010
Purple Jesus Ron Cooper 9/15/2010   

_______________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote