Question: Please its a computer science 101. Please code the practice below by following the steps provided. Use simple language of coding. Its a java program

Please its a computer science 101. Please code the practice below by following the steps provided. Use simple language of coding. Its a java program (i will code on JGRASP) public class....

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 newName

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: newNumberOfPages

Return Type: void

Task: sets the value of the instance variable numberOfPages to newNumberOfPages if the

newNumberOfPages 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 T

ask: 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

//myFavoriteBook

//declare a variable called option of type int

//Open a do/while loop

//Prompt the user to pick one of the following options:

//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

//Press 5 to end the program

//Save the users 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

//change the name of the book to newName

//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

//newNumberOfPages

//change the number of pages of the book to newNumberOfPages

//else if the user picks option 3, prompt the user for the current

//page and save the current page in a variable called newCurrentPage

//change the currentPage of the book to newCurrentPage

//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!

//close 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!