Question:
Java program to calculate how much you would weigh on the moon?
Code:
import java.util.Scanner; public class MoonWeight { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter your weight: "); double normalWeight = input.nextDouble(); double weightOnMoon = normalWeight * (16.5 / 100); System.out.println("Your weight on moon is: " + weightOnMoon ); } }
Output:
$ java MoonWeight Enter your weight: 100 Your weight on moon is : 16.5