Question: langauge is java. please help with these two questions. i forgot to submit additional info for step 1 in previous post. i cannot add any


Step 1 Develop the following class: Class Name: Book Access Modifier: public Instance variables Name: name Access modifier: private Data Type: String Name: numberOfPages Access modifier: private Data Type: int Name: currentPage Access modifier: private Data Type: int Constructors: Name: Book Access modifier: public Parameters: none (default constructor) Task: sets the value of the instance variable name to the No Name Yet sets the value of the instance variable numberOfPages to 0 sets the value of the instance variable currentPage to 0 Methods Name: setName Access modifier public Parameters: newName Return Type: void Task: sets the value of the instance variable name to new Name Name: getName Access modifier: public Parameters: none Return Type: String Task: returns the value of the instance variable name Name: setNumberOfPages Access modifier: public Parameters: new NumberOfPages Return Type: void Task: sets the value of the instance variable numberOfPages to new NumberOfPages if the new NumberOfPages is greater than 0 and greater than or equal to the value of the instance variable currentPage Name: getNumberOfPages Access modifier: public Parameters: none Return Type: int Task: returns the value of the instance variable numberOfPages Name: setCurrentPage Access modifier: public Parameters: newCurrentPage Return Type: void Task: sets the value of the instance variable currentPage to newCurrentPage if newCurrentPage is greater than 0 and less than or equal to the value of the instance variable numberOfPages Name: getCurrentPage Access modifier: public Parameters: none Return Type: int Task: returns the value of the instance variable currentPage Step 2 Develop a class with only a main method in it: import java.util.Scanner; public class BookDemo public static void main(String[] args) { //Create a Scanner object called keyboard that takes input from //System.in //Create an object of the Book class refer to this object as //my FavoriteBook 1/declare a variable called option of type int 1/Open a do/while loop 1/Prompt the user to pick one of the following options: 7/Press 1 to change the name of the book //Press 2 to change the number of pages in the book //Press 3 to change the current page //Press 4 to view all information about the book 7/Press 5 to end the program // Save the user's input into the option variable //if the user picks option 1, prompt the user for the name of the book //then save the name of the book in a variable called newName 7/change the name of the book to nawName //else if the user picks option 2, prompt the user for the number of //pages in the book then save the number of pages in a variable called /ewNumberOfPages // change the number of pages of the book to newlumberOfPages //else if the user picks option 3, prompt the user for the current 1 / page and save the current page in a variable called newCurrentPage 1/change the currentPage of the book to newCurrentPage 1/else if the user picks option 4, display to the screen the name of the book, the number of pages in the book, and the current page of the book //else if the user picks option 5. display Goodbye. //else if the user picks any other option, display Error! Welose the do/while loop and make it so that it continues to run as //long as the user does not pick option 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
