In: Computer Science
Develop a Java program for this problem where the user inputs an Earth age and the program will then display the age on Mercury, Venus, Jupiter, and Saturn. The values for d are listed in the table.
Planet |
d = Approximate Number of Earth |
Mercury |
88 |
Venus |
225 |
Jupiter |
4380 |
Saturn |
10767 |
Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate
the question. Thank You So Much.
package classes5;
import java.util.Scanner;
public class AgeCalculator {
public static void main(String[] args) {
System.out.print("Enter age on
earth : ");
Scanner sc = new
Scanner(System.in);
int age = sc.nextInt();
double mercuryAge =
age*365.0/88;
double VenusAge =
age*365.0/225;
double JupiterAge =
age*365.0/4380;
double SaturnAge =
age*365.0/10767;
System.out.println("Age on Mercury
"+mercuryAge);
System.out.println("Age on Venus
"+VenusAge);
System.out.println("Age on Jupiter
"+JupiterAge);
System.out.println("Age on Saturn
"+SaturnAge);
}
}