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

Write a Java class, called Book, to manage information about a particular book:

ID: 665612 • Letter: W

Question

Write a Java class, called Book, to manage information about a particular book: its title, author, publication year, ISBN number and the text of the book (as lines of text). a) Write skeleton code for fields and a constructor of the Book class. The types of the fields and signatures of the constructor should be shown clearly. But you are not required to write the code for the constructor: just show its signature. b) Write a method wordCount for the Book class that returns the total number of words in the text of a book. Use a simple definition for a word, such as any white space separated string.

Explanation / Answer

public class Book{
   static String title, author, isbn, text;
   int year;

// a
   Book(String, String, int, String, String){
      
   }

// b


   public static int wordCount(){
       int count = 0;
       for(int i = 0; i < text.length(); i++){
           if(text.charAt(i) == ' ') count++;
       }
       return count;
   }

}

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