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

Write Full java program to that define Book class contents a) ISBN int. b) BookN

ID: 3817836 • Letter: W

Question

Write Full java program to that define Book class contents a) ISBN int. b) BookName String. c) Author String. d) Edition double. e) Default constructor to assign default values for variables. f) Constructor to receive and assign values to variables. g) Method named view() to print all variables. h) Method named getCharFromBookName(int), to return charter in specified index of book name. i) Method named getLastIndexFromAuthor(char), to get returns index of last occurrence of specified character. j) Main method to test all methods.

Explanation / Answer

public class Book {
  
   public int ISBN;
   public String BookName;
   public String Author;
   public double Edition;
  
   public Book() {};
  
   public Book(int ISBN,String BookName,String Author,double Edition)
   {
   this.ISBN = ISBN;
      this.BookName = BookName;
      this.Author = Author;
      this.Edition = Edition;
   }

   public void view() {
       System.out.println(this.ISBN);
    System.out.println(this.BookName);
       System.out.println(this.Author);
       System.out.println(this.Edition);
   }

   public char getCharFromBookName(int x)
   {
    return BookName.charAt(x);
   }
  
    public int getLastIndexFromAuthor(char ch)
   {
    return Author.lastIndexOf(ch);
   }
  
  
public static void main(String args[]) {
Book ob = new Book(1,"Java Programing"," Balagurusamy",4);
ob.view();
System.out.println("Char at specified index is :" + ob.getCharFromBookName(3));
System.out.println("Last Index of specified char is :" +ob.getLastIndexFromAuthor('r'));
  
}
}

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