/** * Weight Calculator > Essentials2.java * * Displays your calculated weight on the moon using console output. * Illustrates variable declarations, identifiers, initialization, assignment, * arithmetic expression, string concatenation, escape sequences * * @author Dale Reed */ public class Essentials2 { public static void main(String[] args) { // variable declarations int earthWeight; // weight on the earth // Set the weight on earth. In the future we will get this from the user. earthWeight = 220; // time to go on a diet... // compute the result double moonweight; // weight on the moon moonweight = earthWeight * 0.15; //display the result System.out.print( "If on earth you weigh " + earthWeight + " pounds,"); System.out.println( " on the moon you'll weigh " + moonweight + " \n\n"); } } /* Output: If on earth you weigh 220 pounds, on the moon you'll weigh 33.0 */