Question
Student.java is linked to 2 other java docs I already wrote. This is my code for Student.java, could you please help me figure out the
Student.java is linked to 2 other java docs I already wrote.
This is my code for Student.java, could you please help me figure out the compilation errors I'm getting and how I can fix them
Compilation errors:
Student.java:14: error: cannot find symbol book.daysUntilOverdue()--; //decrease the number of days until overdue for the book that the student checked out ^ symbol: method daysUntilOverdue() location: variable book of type Book Student.java:15: error: cannot find symbol if(book.isCheckedOut()) { //If the student has a book ^ symbol: method isCheckedOut() location: variable book of type Book Student.java:25: error: cannot find symbol if(book.isCheckedOut()) { ^ symbol: method isCheckedOut() location: variable book of type Book Student.java:41: error: cannot find symbol if(library.getBooks()[index].isCheckedOut()) { //If the book at that index is checked out ^ symbol: method isCheckedOut() location: class Book Student.java:48: error: cannot find symbol if (book == null || book.isCheckedOut() == false) { //If the student does not have a book ^ symbol: method isCheckedOut() location: variable book of type Book 5 errors
My file:
Student.java This class will have the following private instance variables: String name - represents the name of the student. Book book - represents the book the student checked out. double debt - represents the debt a student must pay for overdue books. This class will have the following constructor: Student(String name) - this should initialize the student's name with the passed in value. This class will have the following public instance methods String toString() - this method will decrease the number of days until overdue for the book that the student checked out. o If the student has a book, return "You have book title checked out and [days until overdue) days until it's due. o If the student does not have a book, return "You have no library books" void checkOut(Library library) - for this method, you will need to pick a random index and get the book at that index from the Library. Then assign this book to the instance book. o Be sure to set this book as "checkedOut. o If the book is already checked Out, print "This book is already checked out!" and don't assign this to book. o If the library is empty, then print "Sorry, this library is empty.. O Also set the days until due date for the book to be 3 days. void checkOut(int index, Library library) - for this method, you will be checking out a book from the Library at that given index, similar to the checkOut(Library library) method above. However: If the index is greater than size of the library, print out "The library is not that big yet!". If the book at that index is checked out, print out This book is already checked out!" and don't assign it to book. Also set the days until due date for the book to be 3 days. void returnBook () - this method will return a book back to the library. o If the student does not have a book, print out "You have no book to return!". o If the student does have a book, set the book's checkout variable to be false and daysUntiloverdue to 0. However, if the book's daysUntiloverdue is less than 0, then the student must pay a debt of $5. Print out "You will be charged $5 for returning this book late." void payDebt (double pay) - This method should decrease the student's debt by pay. o If the student has no debt, print out You have no debt to pay off. . However, if the pay is greater than the debt, then set debt to 0. public class Student { private String name; //represents the name of the student private Book book; //represents the book the student checked out private double debt; //represents the debt a student must pay for overdue books // Constructor public Student(String name) { //this should initialize the student's name with the passed in value this.name = name; // Methods public String toString({ // decrease the number of days until overdue for the book that the student checked out! //daysUntiloverdue--; //decrease the number of days until overdue for the book that the student checked out if(book.ischeckedout()) { //If the student has a book return "You have " + book.getTitle() + " checked out and " + book.getDaysUntiloverdue() + " days until it's due" } else { //If the student does not have a book return "You have no library books"; public void checkout(Library Library) { //pick a random index and get the book at that index from the Library // Generating random index int index = (int) (Math.random() * library.getSize()); this.book = library.getBooks ([index]; //assign book from Library to the instance book, if(book.isCheckedout()) { System.out.println("This book is already checked out!") } else { book.setCheckedout(true); // set the days until due date for the book to be 3 days book.setDaysUntiloverdue (3); if (library.getSize() == 0) { System.out.println("Sorry, this library is empty."); public void checkout(int index, Library Library) { // check out a book from the Library at that given if(index > library.getSize()) { //If the index is greater than size of the library, System.out.println("The library is not that big yet!"); if(library.getBooks()[index].isCheckedout()) { //If the book at that index is checked out System.out.println("This book is already checked out!"); book.setDaysUntiloverdue (3); //set the days until due date for the book to be 3 days } public void returnBook() { //return a book back to the library if (book == null || book.isCheckedout() == false) { //If the student does not have a book, System.out.println("You have no book to return!"); } else { //If the student does have a book, if (book.getDaysUntiloverdue() debt) { debt = 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started