Warnings appear when half the Once started, this test must be completed in one s
ID: 3739941 • Letter: W
Question
Warnings appear when half the Once started, this test must be completed in one sitting Do not leave the test before clicking Save and Submit This test does not allow backtracking Changes to the answer after submission are prohibited time, 5 hinuies iple This test allows 3 attempts. This is attempt number 1 mpts ?? mpletion Remaining Time: 1 hour, 18 minutes, 28 seconds. Question Completion Status: Moving to the next question prevents changes to this answer stion 19 Create a class called SolarSystems . Create two data members and two member functions of SolarSystem Create two objects i e mars and Puto from class Solarsystem & call member function on these two (temas & · TTT Arial 3(12pt) ?T·-·-· ? Path. p às Moving to the next question prevents changes to this answerExplanation / Answer
Below is your code in Java. Let me know if you have any issues in this
public class SolarSystem {
//Data variables
double distance;
double weight;
// Default Constructor
SolarSystem() {
}
// method to display the result
void display() {
System.out.println("Distance : " + distance+" miles");
System.out.println("Weight : " + weight+ " tonn");
}
// method to setValues
void setValues(double d, double w) {
this.distance = d;
this.weight = w;
}
//method to run the function
public static void main(String[] args) {
//creating two objects
SolarSystem mars = new SolarSystem();
SolarSystem pluto = new SolarSystem();
//calling setValues() method
mars.setValues(120349.3, 1223.2);
pluto.setValues(23242.3, 3232.2);
//calling display method
System.out.println("Details of the Mars: ");
mars.display();
System.out.println("Details of the Pluto: ");
pluto.display();
}
}
Output
Details of the Mars:
Distance : 120349.3 miles
Weight : 1223.2 tonn
Details of the Pluto:
Distance : 23242.3 miles
Weight : 3232.2 tonn
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.