Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You design a class named Book. This class needs to have following member variables and member methods: Member Variables private String data field named title

You design a class named Book. This class needs to have following member variables and member methods:

Member Variables

private String data field named title

private double data field name discount that specifies the percentage of sale for a book sale (default is zero)

private double data field name unitPrice (default is 0)

private int data field named quantity (default is 0)

Constructors

Default constructor:

public Book()

public Book(int q, String t) with parameter of quantity and title of the book sale

public Book(int q, String t, double r) (with the quantity q, title t, and discount of r)

Methods

The accessor and mutator methods for all four data fields

A method named calculateSale() to calculate the sale of the book

A method named toString() that returns string description of the computer.

You need to implement a TestBook class. In this Test class, you need to create three Book objects (book1, book2, and book3) using different constructors. Change the value of book1 (created by default) with users input values of title of Java, unit price of 90 dollars, quantity of 52 and discount of 0.1. Get users input for title, quantity and unit price to create book2 with discount of 0.1 using second constructor. After that, get users input for title, quantity and unit price for book3, and change book3s discount to 0.15.

Display objects by invoking their toString method.

Create a class diagram in UML notation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions