Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q2) write a java program with the following steps: 1- Create a java class file Book which has the following properties: Book -title: String -price:double
Q2) write a java program with the following steps: 1- Create a java class file Book which has the following properties: Book -title: String -price:double -category: String -authorName:Author +constructors (you should include all the needed constructors) +getters and setters(you should include the setters and getters needed for data members) +override method toString():String (represent the book with all its information) +override method equals(Book b):boolean (it will check the equality of any two books according to their title) Note: Category data member takes historical, Health, or academic value. 2- Create another java class file Author which has the following properties: Author -name:String -gender:String +constructors (you should include all the needed constructors) +getters and setters(you should include the setters and getters needed for data members) +override method toString():String (represent the author with all his/her information) +override method equals(Author a):boolean (it will check the equality of any two authors according to their name and gender. Note: gender data member takes Male or Female value. 3- Create java main class file Test1 and do the following: A) Declare an array allBooks of type book with size 3. B) Print the following menu to give the user optionality: Choose 1 to insert a new book. Choose 2 to retrieve historical books. Choose 3 to check the equality of first and last books in the array. Choose O to exit. C) When the user chooses the first choice, you should check the allBooks array if it is full then give him/her a "sorry, you reach the maximum length" message else prompt from the user to enter full information for the new book (title, price, type, and the info of author (name and gender)) then print all the books with the new one. D) When the user chooses the second choice, you should retrieve the information of all the books with history type. E) When the user chooses the last choice, you should check the equality of the first book with the last book in the array by using the override method equals (in Book class). Sample Run: Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose 0 to exit. Please enter your choice: 1 Please enter the title: Introduction to java programming. Please enter the price: 35 Please enter the type: Academic Please enter the author name: Dietel Liang 8/10 Please enter his/her gender: Male The allBooks array contains: Introduction to java programming 35 his author Dietel Liang Male Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose O to exit. Please enter your choice: 1 Please enter the title: History of the Caliphs Please enter the price: 57 Please enter the type: Historical Please enter the author name: Jalaluddin Al-Suyuti Please enter his/her gender: Male The allBooks array contains: Introduction to java programming 35 Academic his author Dietel Liang Male History of the Caliphs 57 Historical his author Jalaluddin Al-Suyuti Male 9 / 10 Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose O to exit. Please enter your choice: 2 The Historical book/s is/are: History of the Caliphs 57 Historical his author Jalaluddin Al-Suyuti Male Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose O to exit. Please enter your choice: 3 Introduction to java programming not equal to History of the Caliphs. Good Luck
Step 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