Assignment #38 Space Boxing
Code
/// Name: Matthew Lorence
/// Period: 5
/// Program Name: SpaceBoxer
/// File Name: SpaceBoxer.java
/// Date Finished:11/16/15
import java.util.Scanner;
public class SpaceBoxer
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int earth_weight, planet;
double vweight, mweight, jweight, sweight, uweight, nweight;
System.out.print( "Please enter your current earth weight: ");
earth_weight = keyboard.nextInt();
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 3. Uranus 4. Neptune" );
System.out.println();
System.out.print( "Which planet are you visiting? " );
planet = keyboard.nextInt();
vweight = earth_weight * .78;
mweight = earth_weight * .39;
jweight = earth_weight * 2.65;
sweight = earth_weight * 1.17;
uweight = earth_weight * 1.05;
nweight = earth_weight * 1.23;
if ( planet == 1 )
{
System.out.println( "Your weight would be " + vweight + " pounds on that planet." );
}
else if ( planet == 2 )
{
System.out.println( "Your weight would be " + mweight + " pounds on that planet." );
}
else if ( planet == 3 )
{
System.out.println( "Your weight would be " + jweight + " pounds on that planet." );
}
else if ( planet == 4 )
{
System.out.println( "Your weight would be " + sweight + " pounds on that planet." );
}
else if ( planet == 5 )
{
System.out.println( "Your weight would be " + uweight + " pounds on that planet." );
}
else if ( planet == 6 )
{
System.out.println( "Your weight would be " + nweight + " pounds on that planet." );
}
}
}
Picture of the output