Based on the description provided in the Programming Project

Based on the description provided in the Programming Project PP 9.3, page 482, create and test an application that calculates the rating for the holdings in the library collection.

Implement a class hierarchy with at least the LibraryMaterial, Book, Textbook, Novel, Magazine, TechnicalJournal classes. The LibraryMaterial class must be implemented as an abstract class. When calculating the rating:

for Books, Textbooks and Novels: divide the price by the actual number of pages,

for Magazines and TechnicalJournals: divide the price by 10 (always),

(If you proposed more classes then you also need to propose different rating calculations for each one of them.)

Create a main driver class and instantiate in an array several objects from the classes described above. Calculate the overall rating for the holding in the entire library (just add the rating for all individual items). Then print all the items in the library holdings in the ascending order of their individual ratings. When sorting through the library holdings you MUST use the insertionSort method from Listing 10.9 AS IS WITH NO CHANGES TO THE CODE.

Instructions:

Show the class hierarchy on a UML diagram (like e.g. Figure 9.1, page 449). You may draw the diagram by hand or use a drawing package (e.g. https://www.gliffy.com/uses/uml-software/ )

2.


Do not forget to include comments as per Java Coding Guidelines described in Appendices F and I.

Your electronic submission (submitted via Desire2Learn) will consist of two files:

(i)a written report consisting of three sections, with each part clearly identified with a section heading:

a.a UML diagram

b.all of the source code, and

c.the output captured from the terminal window.

Solution

abstract class LibraryMaterial
{
protected double rate;
public abstract void getRate();

public void CalculateBill(int nopages)
{
System.out.println(\"Bill amount for \"+nopages+\"nopages:\");
System.out.println(rate*nopages);
}

public void CalculateBill1(int nopages)
{
System.out.println(\"Bill amount for \"+nopages+\"nopages:\");
System.out.println((rate*nopages)/10);
}
}

class Books extends LibraryMaterial
{
public void getRate()
{
rate=2.60;
}
}

class TextbooksNovels extends LibraryMaterial
{
public void getRate()
{
rate=2.60;
}
}

class MagazinesTechnicalJournals extends LibraryMaterial
{
public void getRate()
{
rate=5.00;
}
}


class Calculate
{
public static void main(String args[])
{
LibraryMaterial p;
System.out.println(\"Bill for Books:\");
p=new Books();
p.getRate();
p.CalculateBill(250);

System.out.println(\"Bill for extbooks and Novels:\");
p=new TextbooksNovels();
p.getRate();
p.CalculateBill(150);

System.out.println(\"Magazines and TechnicalJournals:\");
p=new TextbooksNovels();
p.getRate();
p.CalculateBill1(150);
}
}

changr code according to your requirements is possible in future.Thank you

Based on the description provided in the Programming Project PP 9.3, page 482, create and test an application that calculates the rating for the holdings in the
Based on the description provided in the Programming Project PP 9.3, page 482, create and test an application that calculates the rating for the holdings in the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site