Assignment #38
Code
///Name: Cody Swain
///Period: 6
///Project Name: SpaceBoxing
///File Name: SpaceBoxing.java
///Date: 10/14/15
import java.util.Scanner;
public class SpaceBoxing
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int eweight; //earth weight
int planet;
System.out.println( "Please enter your current earth weight: " );
eweight = keyboard.nextInt();
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();
if ( planet == 1 )
{
System.out.println( "Your weight would be " + (eweight * .78) + " on that planet." );
}
else if ( planet == 2 )
{
System.out.println( "Your weight would be " + (eweight * .39) + " on that planet." );
}
else if ( planet == 3 )
{
System.out.println( "Your weight would be " + (eweight * 2.65) + " on that planet." );
}
else if ( planet == 4 )
{
System.out.println( "Your weight would be " + (eweight * 1.17) + " on that planet." );
}
else if ( planet == 5 )
{
System.out.println( "Your weight would be " + (eweight * 1.05) + " on that planet." );
}
else if ( planet == 6 )
{
System.out.println( "Your weight would be " + (eweight * 1.23) + " on that planet." );
}
else System.out.println( "Error. ");
}
}
Picture of the output