/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome to the Planet Distance Calculator!");
System.out.println("Enter the planet you want to know about (e.g., Mars, Jupiter, Saturn, Venus, Mercury, Uranus, and Neptune):");
String planetName = scanner.nextLine();
displayPlanetInfo(planetName);
scanner.close();
}
public static void displayPlanetInfo(String planetName) {
String lowerCasePlanet = planetName.toLowerCase();
switch (lowerCasePlanet) {
case "mars":
System.out.println("\n--- Mars ---");
System.out.println("Average distance from Earth: Approximately 140 million miles.");
System.out.println("Details: The fourth planet from the Sun, Mars is a rocky, dry, and cold planet, known for its red appearance. It has two small moons, Phobos and Deimos.");
break;
case "jupiter":
System.out.println("\n--- Jupiter ---");
System.out.println("Average distance from Earth: Approximately 444 million miles.");
System.out.println("Details: The largest planet in our solar system and the fifth from the Sun, Jupiter is a gas giant primarily composed of hydrogen and helium.");
break;
case "saturn":
System.out.println("\n--- Saturn ---");
System.out.println("Average distance from Earth: Approximately 746 million miles.");
System.out.println("Details: The sixth planet from the Sun and the second largest, Saturn is a magnificent gas giant, it also has a large number of moons, with Titan being its largest.");
break;
case "venus":
System.out.println("\n--- Venus ---");
System.out.println("Average distance from Earth: Approximately 25 million miles.");
System.out.println("Details: Earth's closest planetary neighbor and the second planet from the Sun.");
break;
case "mercury":
System.out.println("\n--- Mercury ---");
System.out.println("Average distance from Earth: Approximately48 million miles.");
System.out.println("Details: The smallest planet and the closest to the Sun, Mercury is a rocky planet with a heavily cratered surface.");
break;
case "uranus":
System.out.println("\n--- Uranus ---");
System.out.println("Average distance from Earth: Approximately 1.8 billion miles.");
System.out.println("Details: The seventh planet from the Sun, Uranus is an ice giant known for its unique tilt, causing it to essentially orbit on its side.");
break;
case "neptune":
System.out.println("\n--- Neptune ---");
System.out.println("Average distance from Earth: Approximately 2.8 billion miles.");
System.out.println("Details: The eighth and farthest known planet from the Sun, Neptune is another ice giant characterized by strong winds and dynamic storms in its atmosphere.");
break;
default:
System.out.println("Sorry, information for '" + planetName + "' is not recognized. Please try another planet.");
break;
}
}
}