SlideShare uma empresa Scribd logo
1 de 1
Baixar para ler offline
Write a Book class (Book.java) and test it with the provided TestBook.java.
Your Book class should be implemented with:
(1) instance variables:
bookTitle (private string);
numPages (private int);
authorName (private string);
price (private double);
(2) constructors
a default constructor (set your book title as "Unknown Book", num of pages as 0, author Name as
"ABCD", price as 1.0)
a user-defined constructor (take four input arguments in the order of book title, number of pages,
author name and price. Assign each argument to the corresponding instance variable)
(3) getters and setters
a setter method setPrice to change the price
a getter method getNumOfPages to return the number of pages as an integer
(4) two methods
method name: pricePerPage - calculate the price per page (price / numPages) and return it as a
double
method name: toString - return a long string, which must include the values of bookTitle,
numPages, authorName and price.
This is the TestBook.java. code

Mais conteúdo relacionado

Mais de advancesystem

Write a Fortran program to SOS take the name and ID number.pdf
Write a Fortran program to  SOS  take the name and ID number.pdfWrite a Fortran program to  SOS  take the name and ID number.pdf
Write a Fortran program to SOS take the name and ID number.pdfadvancesystem
 
Write a function that will take four parameters omega x0.pdf
Write a function that will take four parameters omega  x0.pdfWrite a function that will take four parameters omega  x0.pdf
Write a function that will take four parameters omega x0.pdfadvancesystem
 
Write a function that will take four parameters omega p.pdf
Write a function that will take four parameters omega  p.pdfWrite a function that will take four parameters omega  p.pdf
Write a function that will take four parameters omega p.pdfadvancesystem
 
Write a generalpurpose program with loop and indexed addres.pdf
Write a generalpurpose program with loop and indexed addres.pdfWrite a generalpurpose program with loop and indexed addres.pdf
Write a generalpurpose program with loop and indexed addres.pdfadvancesystem
 
Write a computer program in JAVA that hides a secret message.pdf
Write a computer program in JAVA that hides a secret message.pdfWrite a computer program in JAVA that hides a secret message.pdf
Write a computer program in JAVA that hides a secret message.pdfadvancesystem
 
Write a Fortran program to 1 take the name and ID number of.pdf
Write a Fortran program to 1 take the name and ID number of.pdfWrite a Fortran program to 1 take the name and ID number of.pdf
Write a Fortran program to 1 take the name and ID number of.pdfadvancesystem
 
Write a function called ApologyLine that take an integer c a.pdf
Write a function called ApologyLine that take an integer c a.pdfWrite a function called ApologyLine that take an integer c a.pdf
Write a function called ApologyLine that take an integer c a.pdfadvancesystem
 
Write a C++ code that makes pyramid shape as long as user wa.pdf
Write a C++ code that makes pyramid shape as long as user wa.pdfWrite a C++ code that makes pyramid shape as long as user wa.pdf
Write a C++ code that makes pyramid shape as long as user wa.pdfadvancesystem
 
Write a class called Window that contains the following info.pdf
Write a class called Window that contains the following info.pdfWrite a class called Window that contains the following info.pdf
Write a class called Window that contains the following info.pdfadvancesystem
 
Write a C code that uses struct to create a userdefined typ.pdf
Write a C code that uses struct to create a userdefined typ.pdfWrite a C code that uses struct to create a userdefined typ.pdf
Write a C code that uses struct to create a userdefined typ.pdfadvancesystem
 
Write a 12 page report on igneous rock and how they are m.pdf
Write a 12 page report on igneous rock and  how they are m.pdfWrite a 12 page report on igneous rock and  how they are m.pdf
Write a 12 page report on igneous rock and how they are m.pdfadvancesystem
 
WQ4 Coevolution of Central American ants in the Pseudomyrme.pdf
WQ4 Coevolution of Central American ants in the Pseudomyrme.pdfWQ4 Coevolution of Central American ants in the Pseudomyrme.pdf
WQ4 Coevolution of Central American ants in the Pseudomyrme.pdfadvancesystem
 
With the following companies Apple Caterpillar Consolidat.pdf
With the following companies Apple Caterpillar Consolidat.pdfWith the following companies Apple Caterpillar Consolidat.pdf
With the following companies Apple Caterpillar Consolidat.pdfadvancesystem
 
Would the current answer be considered correct 2 Identify .pdf
Would the current answer be considered correct 2 Identify .pdfWould the current answer be considered correct 2 Identify .pdf
Would the current answer be considered correct 2 Identify .pdfadvancesystem
 
WQ3 Considering that you know about natural selection is o.pdf
WQ3 Considering that you know about natural selection is o.pdfWQ3 Considering that you know about natural selection is o.pdf
WQ3 Considering that you know about natural selection is o.pdfadvancesystem
 
would be earned How much of the total is simple interest an.pdf
would be earned How much of the total is simple interest an.pdfwould be earned How much of the total is simple interest an.pdf
would be earned How much of the total is simple interest an.pdfadvancesystem
 
write 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdf
write 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdfwrite 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdf
write 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdfadvancesystem
 
World vegetation maps and world climate maps are very simila.pdf
World vegetation maps and world climate maps are very simila.pdfWorld vegetation maps and world climate maps are very simila.pdf
World vegetation maps and world climate maps are very simila.pdfadvancesystem
 
Working with Dictionaries and ListsSets Modules you can use.pdf
Working with Dictionaries and ListsSets Modules you can use.pdfWorking with Dictionaries and ListsSets Modules you can use.pdf
Working with Dictionaries and ListsSets Modules you can use.pdfadvancesystem
 
Working individually or in pairs you will apply what you ha.pdf
Working individually or in pairs you will apply what you ha.pdfWorking individually or in pairs you will apply what you ha.pdf
Working individually or in pairs you will apply what you ha.pdfadvancesystem
 

Mais de advancesystem (20)

Write a Fortran program to SOS take the name and ID number.pdf
Write a Fortran program to  SOS  take the name and ID number.pdfWrite a Fortran program to  SOS  take the name and ID number.pdf
Write a Fortran program to SOS take the name and ID number.pdf
 
Write a function that will take four parameters omega x0.pdf
Write a function that will take four parameters omega  x0.pdfWrite a function that will take four parameters omega  x0.pdf
Write a function that will take four parameters omega x0.pdf
 
Write a function that will take four parameters omega p.pdf
Write a function that will take four parameters omega  p.pdfWrite a function that will take four parameters omega  p.pdf
Write a function that will take four parameters omega p.pdf
 
Write a generalpurpose program with loop and indexed addres.pdf
Write a generalpurpose program with loop and indexed addres.pdfWrite a generalpurpose program with loop and indexed addres.pdf
Write a generalpurpose program with loop and indexed addres.pdf
 
Write a computer program in JAVA that hides a secret message.pdf
Write a computer program in JAVA that hides a secret message.pdfWrite a computer program in JAVA that hides a secret message.pdf
Write a computer program in JAVA that hides a secret message.pdf
 
Write a Fortran program to 1 take the name and ID number of.pdf
Write a Fortran program to 1 take the name and ID number of.pdfWrite a Fortran program to 1 take the name and ID number of.pdf
Write a Fortran program to 1 take the name and ID number of.pdf
 
Write a function called ApologyLine that take an integer c a.pdf
Write a function called ApologyLine that take an integer c a.pdfWrite a function called ApologyLine that take an integer c a.pdf
Write a function called ApologyLine that take an integer c a.pdf
 
Write a C++ code that makes pyramid shape as long as user wa.pdf
Write a C++ code that makes pyramid shape as long as user wa.pdfWrite a C++ code that makes pyramid shape as long as user wa.pdf
Write a C++ code that makes pyramid shape as long as user wa.pdf
 
Write a class called Window that contains the following info.pdf
Write a class called Window that contains the following info.pdfWrite a class called Window that contains the following info.pdf
Write a class called Window that contains the following info.pdf
 
Write a C code that uses struct to create a userdefined typ.pdf
Write a C code that uses struct to create a userdefined typ.pdfWrite a C code that uses struct to create a userdefined typ.pdf
Write a C code that uses struct to create a userdefined typ.pdf
 
Write a 12 page report on igneous rock and how they are m.pdf
Write a 12 page report on igneous rock and  how they are m.pdfWrite a 12 page report on igneous rock and  how they are m.pdf
Write a 12 page report on igneous rock and how they are m.pdf
 
WQ4 Coevolution of Central American ants in the Pseudomyrme.pdf
WQ4 Coevolution of Central American ants in the Pseudomyrme.pdfWQ4 Coevolution of Central American ants in the Pseudomyrme.pdf
WQ4 Coevolution of Central American ants in the Pseudomyrme.pdf
 
With the following companies Apple Caterpillar Consolidat.pdf
With the following companies Apple Caterpillar Consolidat.pdfWith the following companies Apple Caterpillar Consolidat.pdf
With the following companies Apple Caterpillar Consolidat.pdf
 
Would the current answer be considered correct 2 Identify .pdf
Would the current answer be considered correct 2 Identify .pdfWould the current answer be considered correct 2 Identify .pdf
Would the current answer be considered correct 2 Identify .pdf
 
WQ3 Considering that you know about natural selection is o.pdf
WQ3 Considering that you know about natural selection is o.pdfWQ3 Considering that you know about natural selection is o.pdf
WQ3 Considering that you know about natural selection is o.pdf
 
would be earned How much of the total is simple interest an.pdf
would be earned How much of the total is simple interest an.pdfwould be earned How much of the total is simple interest an.pdf
would be earned How much of the total is simple interest an.pdf
 
write 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdf
write 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdfwrite 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdf
write 350400 WORDS AND EXPLAIN BRIEFLY lapter 7 How Touris.pdf
 
World vegetation maps and world climate maps are very simila.pdf
World vegetation maps and world climate maps are very simila.pdfWorld vegetation maps and world climate maps are very simila.pdf
World vegetation maps and world climate maps are very simila.pdf
 
Working with Dictionaries and ListsSets Modules you can use.pdf
Working with Dictionaries and ListsSets Modules you can use.pdfWorking with Dictionaries and ListsSets Modules you can use.pdf
Working with Dictionaries and ListsSets Modules you can use.pdf
 
Working individually or in pairs you will apply what you ha.pdf
Working individually or in pairs you will apply what you ha.pdfWorking individually or in pairs you will apply what you ha.pdf
Working individually or in pairs you will apply what you ha.pdf
 

Último

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 

Último (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 

Write a Book class Bookjava and test it with the provided.pdf

  • 1. Write a Book class (Book.java) and test it with the provided TestBook.java. Your Book class should be implemented with: (1) instance variables: bookTitle (private string); numPages (private int); authorName (private string); price (private double); (2) constructors a default constructor (set your book title as "Unknown Book", num of pages as 0, author Name as "ABCD", price as 1.0) a user-defined constructor (take four input arguments in the order of book title, number of pages, author name and price. Assign each argument to the corresponding instance variable) (3) getters and setters a setter method setPrice to change the price a getter method getNumOfPages to return the number of pages as an integer (4) two methods method name: pricePerPage - calculate the price per page (price / numPages) and return it as a double method name: toString - return a long string, which must include the values of bookTitle, numPages, authorName and price. This is the TestBook.java. code