SlideShare a Scribd company logo
1 of 4
Download to read offline
Create a class called Planet (e.g. https://en.wikipedia.org/wiki/Solar_System) . It has instance
variables, constructor parameters, and accessor methods for the following data:
- String name
- boolean innerPlanet
- double astronomicalUnitsFromSun
- double earthMasses
Create a method called getPlanetaryData() which returns a String in the exact format of
“Mercury is an inner planet, weighs 0.055 Earth masses, and is 0.4 AU from the Sun.” or
“Jupiter is an outer planet, weighs 318 Earth masses, and is 5.2 AU from the Sun.”, etc….
Create another method with the signature public Boolean isSimilarToEarth() which returns true
if and only if the Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.
Create a Main class with a main method. The main method creates all eight Planet objects for our
solar system, calls each Planet’s getPlanetaryData() method, and also reports in one sentence for
Planet whether the Planet is similar to Earth, in the format of “Jupiter is not similar to Earth.”.
Solution
public class planet {
String name;
boolean innerplanet;
double astronmicalunitfromsun;
double earthmases;
String planet="";
planet(){
}
planet(String name,boolean innerplanet,double astronmicalunitfromsun,double earthmases){
this.name=name;
this.innerplanet=innerplanet;
this.astronmicalunitfromsun=astronmicalunitfromsun;
this.earthmases=earthmases;
if(innerplanet==true)
planet="inner";
else
planet="outer";
}
public String getname(){
return name;
}
public boolean getinnerplanet(){
return innerplanet;
}
public double getastronmicalunitfromsun(){
return astronmicalunitfromsun;
}
public double getearthmases(){
return earthmases;
}
public void getplanetarydata(){
System.out.println(tostring());
}
public String tostring(){
return name+" is an "+planet+" planet, weighs:" +astronmicalunitfromsun+" Earth masses,
and is"+earthmases+" AU from the Sun";
}
public boolean issimilartoearth(){
if(astronmicalunitfromsun<1||earthmases<15)
return true;
else
return false;
}
}
import java.util.*;
public class lab0604{
public static void main(String args[]){
planet p=new planet("mercury",false,0.055,0.4);
p.getplanetarydata();
boolean issimilar= p.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar);
System.out.println();
planet p2=new planet("mercury",false,0.055,0.4);
p2.getplanetarydata();
boolean issimilar2= p2.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar2);
System.out.println();
planet p3=new planet("mercury",false,0.055,0.4);
p3.getplanetarydata();
boolean issimilar3= p3.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar3);
System.out.println();
planet p4=new planet("jupitar",true,1.055,2.4);
p4.getplanetarydata();
boolean issimilar4= p4.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar4);
System.out.println();
planet p5=new planet("saturn",false,2.3,0.1);
p5.getplanetarydata();
boolean issimilar5= p5.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar5);
System.out.println();
planet p6=new planet("mars",false,3.055,-0.4);
p6.getplanetarydata();
boolean issimilar6= p6.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar6);
System.out.println();
planet p7=new planet("pluto",false,2.055,0.34);
p7.getplanetarydata();
boolean issimilar7= p7.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar7);
System.out.println();
planet p8=new planet("venus",false,0.055,0.4);
p8.getplanetarydata();
boolean issimilar8= p8.issimilartoearth();
System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth
masses."+issimilar8);
}
}
output:
mercury is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true
mercury is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true
mercury is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true
jupitar is an inner planet, weighs:1.055 Earth masses, and is2.4 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true
saturn is an outer planet, weighs:2.3 Earth masses, and is0.1 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true
mars is an outer planet, weighs:3.055 Earth masses, and is-0.4 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true
pluto is an outer planet, weighs:2.055 Earth masses, and is0.34 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true
venus is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun
Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true

More Related Content

More from RAJATCHUGH12

What is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdfWhat is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdfRAJATCHUGH12
 
What are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdfWhat are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdfRAJATCHUGH12
 
The Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdfThe Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdfRAJATCHUGH12
 
The distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdfThe distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdfRAJATCHUGH12
 
t hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdft hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdfRAJATCHUGH12
 
Rewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdfRewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdfRAJATCHUGH12
 
Need help answering these. Underline the correct answer The fundame.pdf
Need help answering these. Underline the correct answer  The fundame.pdfNeed help answering these. Underline the correct answer  The fundame.pdf
Need help answering these. Underline the correct answer The fundame.pdfRAJATCHUGH12
 
Origins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdfOrigins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdfRAJATCHUGH12
 
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfListings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfRAJATCHUGH12
 
In hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdfIn hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdfRAJATCHUGH12
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfRAJATCHUGH12
 
How does differ from evolution systematic Only cladistics traces e.pdf
How does  differ from evolution systematic  Only cladistics traces e.pdfHow does  differ from evolution systematic  Only cladistics traces e.pdf
How does differ from evolution systematic Only cladistics traces e.pdfRAJATCHUGH12
 
Giving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdfGiving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdfRAJATCHUGH12
 
Explain why conditions that cause destruction ibB lymphocytes and .pdf
Explain why conditions that cause destruction ibB lymphocytes and  .pdfExplain why conditions that cause destruction ibB lymphocytes and  .pdf
Explain why conditions that cause destruction ibB lymphocytes and .pdfRAJATCHUGH12
 
Exercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdf
Exercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdfExercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdf
Exercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdfRAJATCHUGH12
 
Do the data shown in the boxplot below have a greater amount of vari.pdf
Do the data shown in the boxplot below have a greater amount of vari.pdfDo the data shown in the boxplot below have a greater amount of vari.pdf
Do the data shown in the boxplot below have a greater amount of vari.pdfRAJATCHUGH12
 
Architectural Innovation The Reconfiguration of Existing Product Te.pdf
Architectural Innovation The Reconfiguration of Existing Product Te.pdfArchitectural Innovation The Reconfiguration of Existing Product Te.pdf
Architectural Innovation The Reconfiguration of Existing Product Te.pdfRAJATCHUGH12
 
Discuss the major capabilities of DBMS and why is a relational DBMS .pdf
Discuss the major capabilities of DBMS and why is a relational DBMS .pdfDiscuss the major capabilities of DBMS and why is a relational DBMS .pdf
Discuss the major capabilities of DBMS and why is a relational DBMS .pdfRAJATCHUGH12
 
Demonstrate your understanding of tree data structure Write a Java .pdf
Demonstrate your understanding of tree data structure Write a Java .pdfDemonstrate your understanding of tree data structure Write a Java .pdf
Demonstrate your understanding of tree data structure Write a Java .pdfRAJATCHUGH12
 
advantages and disadvantages of metro(or)MRT advantages and dis.pdf
advantages and disadvantages of metro(or)MRT advantages and dis.pdfadvantages and disadvantages of metro(or)MRT advantages and dis.pdf
advantages and disadvantages of metro(or)MRT advantages and dis.pdfRAJATCHUGH12
 

More from RAJATCHUGH12 (20)

What is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdfWhat is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdf
 
What are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdfWhat are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdf
 
The Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdfThe Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdf
 
The distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdfThe distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdf
 
t hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdft hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdf
 
Rewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdfRewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdf
 
Need help answering these. Underline the correct answer The fundame.pdf
Need help answering these. Underline the correct answer  The fundame.pdfNeed help answering these. Underline the correct answer  The fundame.pdf
Need help answering these. Underline the correct answer The fundame.pdf
 
Origins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdfOrigins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdf
 
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfListings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
 
In hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdfIn hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdf
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
How does differ from evolution systematic Only cladistics traces e.pdf
How does  differ from evolution systematic  Only cladistics traces e.pdfHow does  differ from evolution systematic  Only cladistics traces e.pdf
How does differ from evolution systematic Only cladistics traces e.pdf
 
Giving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdfGiving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdf
 
Explain why conditions that cause destruction ibB lymphocytes and .pdf
Explain why conditions that cause destruction ibB lymphocytes and  .pdfExplain why conditions that cause destruction ibB lymphocytes and  .pdf
Explain why conditions that cause destruction ibB lymphocytes and .pdf
 
Exercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdf
Exercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdfExercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdf
Exercise 5. Let L Q5 Q5 e the linear operator defined by a, b, c, d, .pdf
 
Do the data shown in the boxplot below have a greater amount of vari.pdf
Do the data shown in the boxplot below have a greater amount of vari.pdfDo the data shown in the boxplot below have a greater amount of vari.pdf
Do the data shown in the boxplot below have a greater amount of vari.pdf
 
Architectural Innovation The Reconfiguration of Existing Product Te.pdf
Architectural Innovation The Reconfiguration of Existing Product Te.pdfArchitectural Innovation The Reconfiguration of Existing Product Te.pdf
Architectural Innovation The Reconfiguration of Existing Product Te.pdf
 
Discuss the major capabilities of DBMS and why is a relational DBMS .pdf
Discuss the major capabilities of DBMS and why is a relational DBMS .pdfDiscuss the major capabilities of DBMS and why is a relational DBMS .pdf
Discuss the major capabilities of DBMS and why is a relational DBMS .pdf
 
Demonstrate your understanding of tree data structure Write a Java .pdf
Demonstrate your understanding of tree data structure Write a Java .pdfDemonstrate your understanding of tree data structure Write a Java .pdf
Demonstrate your understanding of tree data structure Write a Java .pdf
 
advantages and disadvantages of metro(or)MRT advantages and dis.pdf
advantages and disadvantages of metro(or)MRT advantages and dis.pdfadvantages and disadvantages of metro(or)MRT advantages and dis.pdf
advantages and disadvantages of metro(or)MRT advantages and dis.pdf
 

Recently uploaded

Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfJerry Chew
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 

Recently uploaded (20)

Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 

Create a class called Planet (e.g. httpsen.wikipedia.orgwikiSol.pdf

  • 1. Create a class called Planet (e.g. https://en.wikipedia.org/wiki/Solar_System) . It has instance variables, constructor parameters, and accessor methods for the following data: - String name - boolean innerPlanet - double astronomicalUnitsFromSun - double earthMasses Create a method called getPlanetaryData() which returns a String in the exact format of “Mercury is an inner planet, weighs 0.055 Earth masses, and is 0.4 AU from the Sun.” or “Jupiter is an outer planet, weighs 318 Earth masses, and is 5.2 AU from the Sun.”, etc…. Create another method with the signature public Boolean isSimilarToEarth() which returns true if and only if the Planet is less than 1AU from the Sun or weighs less than 15 Earth masses. Create a Main class with a main method. The main method creates all eight Planet objects for our solar system, calls each Planet’s getPlanetaryData() method, and also reports in one sentence for Planet whether the Planet is similar to Earth, in the format of “Jupiter is not similar to Earth.”. Solution public class planet { String name; boolean innerplanet; double astronmicalunitfromsun; double earthmases; String planet=""; planet(){ } planet(String name,boolean innerplanet,double astronmicalunitfromsun,double earthmases){ this.name=name; this.innerplanet=innerplanet; this.astronmicalunitfromsun=astronmicalunitfromsun; this.earthmases=earthmases; if(innerplanet==true) planet="inner"; else planet="outer";
  • 2. } public String getname(){ return name; } public boolean getinnerplanet(){ return innerplanet; } public double getastronmicalunitfromsun(){ return astronmicalunitfromsun; } public double getearthmases(){ return earthmases; } public void getplanetarydata(){ System.out.println(tostring()); } public String tostring(){ return name+" is an "+planet+" planet, weighs:" +astronmicalunitfromsun+" Earth masses, and is"+earthmases+" AU from the Sun"; } public boolean issimilartoearth(){ if(astronmicalunitfromsun<1||earthmases<15) return true; else return false; } } import java.util.*; public class lab0604{ public static void main(String args[]){ planet p=new planet("mercury",false,0.055,0.4);
  • 3. p.getplanetarydata(); boolean issimilar= p.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar); System.out.println(); planet p2=new planet("mercury",false,0.055,0.4); p2.getplanetarydata(); boolean issimilar2= p2.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar2); System.out.println(); planet p3=new planet("mercury",false,0.055,0.4); p3.getplanetarydata(); boolean issimilar3= p3.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar3); System.out.println(); planet p4=new planet("jupitar",true,1.055,2.4); p4.getplanetarydata(); boolean issimilar4= p4.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar4); System.out.println(); planet p5=new planet("saturn",false,2.3,0.1); p5.getplanetarydata(); boolean issimilar5= p5.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar5); System.out.println(); planet p6=new planet("mars",false,3.055,-0.4); p6.getplanetarydata(); boolean issimilar6= p6.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar6); System.out.println(); planet p7=new planet("pluto",false,2.055,0.34);
  • 4. p7.getplanetarydata(); boolean issimilar7= p7.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar7); System.out.println(); planet p8=new planet("venus",false,0.055,0.4); p8.getplanetarydata(); boolean issimilar8= p8.issimilartoearth(); System.out.println(" Planet is less than 1AU from the Sun or weighs less than 15 Earth masses."+issimilar8); } } output: mercury is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true mercury is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true mercury is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true jupitar is an inner planet, weighs:1.055 Earth masses, and is2.4 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true saturn is an outer planet, weighs:2.3 Earth masses, and is0.1 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true mars is an outer planet, weighs:3.055 Earth masses, and is-0.4 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true pluto is an outer planet, weighs:2.055 Earth masses, and is0.34 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true venus is an outer planet, weighs:0.055 Earth masses, and is0.4 AU from the Sun Planet is less than 1AU from the Sun or weighs less than 15 Earth masses.true