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

Write a class called Book.java that has attributes named category, title, author

ID: 645090 • Letter: W

Question

Write a class called Book.java that has attributes named category, title, author, and price.  

Write two constructor methods. One constructor should require title and author and the other constructor should require title only. Write a get method for all attributes and write a set method for all attributes except title. Also write a class method called totalPrice that calculates the price of the book including tax. Assume the tax rate is 6.75%.

Write another class called BookStore that contains a main method. In the main method use input dialog boxes to retrieve information from the user to create a book object. After creating the object, use the getter methods to retrieve the information and use a message box to display the information. Also display the total price which includes tax using the totalPrice method. Below is example output that should be displayed in one message box.

Category: Computer Science
Title: Java Programming
Author: Joyce Farrell
Base Price: $143.28

Total Price: $152.95

Note: The total price shown in the example output is rounded to two decimal places. This is not required however if you do add the code to round to the nearest cent then you can receive additional points to help offset any other point deductions you may receive.

Please help, this is for ch. 4 test so nothing too advanced please.

Explanation / Answer

hope this may helps you..

import java.io.*;

public class Book

{

                int iBookId,iAccessionNumber;

                String sBookName,sAuthor,sPublication;

                DataInputStream in=new DataInputStream(System.in);

               

               

                public void fnRead()

                {

                                try

                                {

                                                System.out.print("Enter BookId : ");

                                                iBookId=Integer.parseInt(in.readLine());

                                               

                                                System.out.print("Enter Accession number : ");

                                                iAccessionNumber=Integer.parseInt(in.readLine());

                                                System.out.print("Enter Book name : ");

                                                sBookName=in.readLine();

               

                                                System.out.print("Enter author's name : ");

                                                sAuthor=in.readLine();

                                                System.out.print("Enter publication : ");

                                                sPublication=in.readLine();

                                }

                                catch(Exception e)

                                {

                                                System.out.println("Invalid data");

                                }

                }

                public void fnDisplay()

                {

                                System.out.println("Book id :" + iBookId);

                                System.out.println("Book Name :" + sBookName);

                                System.out.println("Accession Number : " + iAccessionNumber);

                                System.out.println("Author :" + sAuthor );

                                System.out.println("Publication :" + sPublication);

                }

}

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