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

The program below is what I have and it compiles fine but the professor doesn\'t

ID: 3649629 • Letter: T

Question

The program below is what I have and it compiles fine but the professor doesn't like my output. He wants me to able to borrow any video or books and not just "World Reference" or "Mystic River". Need help for this... Please.


Project:
You are working at the checkout counter of a library and want to write a program that will print out information about the items a borrower has just checked out. The borrower can borrow at least the following items: best selling book, children's book, and videos. They can also try to checkout reference books, but should receive a message that says the reference materials are for use within the library. You are to print out a receipt for borrowers telling them the name of their type of book, and how many days they can borrow the item for. Children's books can be borrowed for 20 days, videos can be borrowed for 3 days, reference materials for 0 days, and best sellers for 10 days. After an item is borrowed it should be marked as unavailable. Every item has a title. Books and videos have a category and children's books have an additional descriptor called reading level. Each type of book should be an extension of a base class that has attributes for the title, the number of borrowing days, and whether the book is available.




import java.util.*;

public class Books
{


String title;
static int checkoutDays;
int bookAvailability;
String readingLevel, category;

public static void main(String[] args){

Books a=new Books();
ReferenceBook b=new ReferenceBook();
BestSeller c=new BestSeller();
ChildrensBooks d=new ChildrensBooks();
Videos e=new Videos();

Scanner in=new Scanner(System.in);
System.out.print("Enter a checkout day: ");
checkoutDays=in.nextInt();

if (checkoutDays == 0)
b.displayreceipt();
else if (checkoutDays ==3)
e.displayreceipt();

else if (checkoutDays ==10)
c.displayreceipt();

else if (checkoutDays ==20)
d.displayreceipt();

else
a.displayreceipt();;



}


public Books()
{
title="";
checkoutDays = 0;
bookAvailability = 0;
}

boolean canBorrow()
{
return false;

}

void displayreceipt()
{
System.out.println("Book is unavailable");
}

}


class ReferenceBook extends Books
{

ReferenceBook()
{
super();
title= ("World Reference");
checkoutDays=0;
}

boolean canBorrow()
{
return false;
}

void displayreceipt()
{
System.out.println("Book is for use in library only");
}

}


class BestSeller extends Books
{
String fiction;

BestSeller()
{
super();
title= ("Mystic River");
checkoutDays=10;
category= fiction;
}

boolean canBorrow()
{
return true;
}

void displayreceipt()
{
System.out.println("Book Name: " + title + "and " + " Days allowed: " + checkoutDays);
}
}


class ChildrensBooks extends Books
{
String easy, fiction;

ChildrensBooks()
{
super();
title= ("Animal Farm");
checkoutDays=20;
category= fiction;
readingLevel= easy;
}

boolean canBorrow()
{
return true;
}

void displayreceipt()
{
// ChildrensBooks();
System.out.println("Book Name: " + title + "and " + " Days allowed: " + checkoutDays);
}
}


class Videos extends Books
{
String learning;

Videos()
{
super();
title= ("Slavery and Amercian Revolution ");
checkoutDays = 3;
category = learning;
}

boolean canBorrow()
{
return true;
}

void displayreceipt()
{
System.out.println("Video Name: " + title + "and " + " Days allowed: " + checkoutDays);
}
}




Explanation / Answer

Java Code: import java.util.*; import java.io.*; public class Books { String title; int checkoutDays; int bookAvailability; public Books() { title=""; checkoutDays = 0; bookAvailability = 0; } boolean canBorrow() { if (checkoutDays > 0) System.out.println("Book Name" + title + "Days allowed: " + checkoutDays); else if (checkoutDays == 0) System.out.println("Book is unavailable"); } }