Using Java, write a program that uses a class to represents a spaceship. A spaceship has some amount of jets, landing gear, parachutes and astronauts. It must leave Earth’s gravity, so it must use all its jets to propel itself off Earth. The spaceship will spend some time exploring before returning to Earth. When it returns to Earth, it will use its parachute and landing gear to land safely. Make sure that those are extended before landing!
Sample output: Your spaceship has 5 astronauts, 2 jets, stored landing gear and parachute.
The spaceship is taking off!
Your spaceship is exploring...
Your spaceship is heading back to Earth.
Oh no! You’re landing gear and parachute weren’t extended! The expedition ended in failure.
Sample output: Your spaceship has 10 astronauts, 4 jets, stored landing gear and parachute.
The spaceship is taking off!
Your spaceship is exploring...
Your spaceship is heading back to Earth.
The landing gear and parachute have been extended!
Your ship has arrived safely back on Earth.
Code -
import java.util.*;
class Spaceship{
int astronauts,jet;
public String toString(){//overriding the toString() method
return "Your spaceship has "+ astronauts +" astronauts, "+jet +"
jets, stored landing gear and parachute.";
}
public void takingOff(){
System.out.println("The spaceship is taking off!");
}
public void exploring(){
System.out.println("Your spaceship is exploring...");
}
public void headingBackToEarth(){
System.out.println("Your spaceship is heading back to
Earth.");
}
public void landingGearsExtended(){
System.out.println("The landing gear and parachute have been
extended! \n Your ship has arrived safely back on Earth.");
}
public void landingGearsNotExtended(){
System.out.println("Oh no! You’re landing gear and parachute
weren’t extended! The expedition ended in failure.");
}
}
public class Main
{
public static void main(String[] args) {
System.out.println("Enter number of
astronauts and jets");
Scanner sc = new
Scanner(System.in);
int astronauts =
sc.nextInt();
int jet = sc.nextInt();
Spaceship ss = new
Spaceship();
ss.astronauts = astronauts;
ss.jet = jet;
System.out.println(ss.toString());
ss.takingOff();
ss.exploring();
ss.headingBackToEarth();
Random random = new Random();
boolean res =
random.nextBoolean();
if(res == true)
ss.landingGearsExtended();
else
ss.landingGearsNotExtended();
}
}
Screenshots -

Using Java, write a program that uses a class to represents a spaceship. A spaceship has...
In Python, write a program that uses a class to represents a spaceship. A spaceship has some amount of jets, landing gear, parachutes and astronauts. It must leave Earth’s gravity, so it must use all its jets to propel itself off Earth. The spaceship will spend some time exploring before returning to Earth. When it returns to Earth, it will use its parachute and landing gear to land safely. Make sure that those are extended before landing! Sample output: Your...