Assignment Description: Write a complete Java program to determine weights on va
ID: 3637190 • Letter: A
Question
Assignment Description:Write a complete Java program to determine weights on various planets. Your weight is actually the amount of gravitational attraction exerted on you by the Earth. Since the Moon's gravity is only one-sixth of the Earths, if you weighed 120 pounds on Earth, you would weigh only 20 pounds on the moon.
This program should ask the user to input his/her Earth weight and output her/his weight on Mercury, Venus, Jupiter and Saturn using the following table:
Multiply the Earth's Weight By
Mercury 0.4
Venus 0.9
Jupiter 2.5
Saturn 1.1
Explanation / Answer
Here is the direct transliteration of your specification Code starts : /*Java program to read earth weight and output weights on other planets*/ import java.io.*; import java.io.DataInputStream; public class weight{ public static void main (String [] args) { double earthW; DataInputStream in = new DataInputStream (System.in); try { System.out.println("Enter earth weight: "); earthW = Double.parseDouble(in.readLine()); System.out.println("Mercury weight : "+0.4*earthW+" Venus weight : "+0.9*earthW); System.out.println("Jupiter weight : "+2.5*earthW+" Saturn weight : "+1.1*earthW); } catch(Exception e){} }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.