Assignment #38 Space Boxing
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Space Boxing
/// File Name: SpaceBoxing.java
/// Date Finished: 10/6/2015
import java.util.Scanner;
public class SpaceBoxing
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int planet;
double weight;
System.out.println();
System.out.print( "Please enter your current earth weight: " );
weight = keyboard.nextDouble();
System.out.println();
System.out.println( "I have information for the following planets:" );
System.out.println( " 1. Venus 2. Mars 3. Jupiter" );
System.out.println( " 4. Saturn 5. Uranus 6. Neptune" );
System.out.println();
System.out.print( "Which planet are you visiting? " );
planet = keyboard.nextInt();
System.out.println();
if ( planet == 1 )
{
System.out.println( "Your weight would be " + ( weight * 0.91 ) + " pounds on that planet." );
}
else if ( planet == 2 )
{
System.out.println( "Your weight would be " + ( weight * 0.38 ) + " pounds on that planet." );
}
else if ( planet == 3 )
{
System.out.println( "Your weight would be " + ( weight * 2.54 ) + " pounds on that planet." );
}
else if ( planet == 4 )
{
System.out.println( "Your weight would be " + ( weight * 1.08 ) + " pounds on that planet." );
}
else if ( planet == 5 )
{
System.out.println( "Your weight would be " + ( weight * 0.91 ) + " pounds on that planet." );
}
else if ( planet == 6 )
{
System.out.println( "Your weight would be " + ( weight * 1.19 ) + " pounds on that planet." );
}
else
{
System.out.println( "That planet is not in our solar system." );
}
}
}
Picture of the output