Assignemnt #38 and Space Boxing
Code
/// Name: David Shkolnikov
/// Period: 6
/// Program Name: Space Boxing
/// File Name: SpaceBoxing.java
/// Date: 10/28/15
import java.util.Scanner;
public class SpaceBoxing
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int weight, planet;
double newWeight=0;
System.out.print( "Please enter your Earth weight here: " );
weight = keyboard.nextInt();
System.out.println( "I have information for the following planets: " );
System.out.println( "\t 1. Venus \t 2. Mars \t 3. Jupiter" );
System.out.println( "\t 4. Saturn \t 5. Uranus \t 6. Neptune" );
System.out.println( " " );
System.out.print( "Which planet are you visiting?" );
planet = keyboard.nextInt();
System.out.println( " " );
if ( planet == 1 )
{
newWeight = weight * .78;
}
else if ( planet == 2 )
{
newWeight = weight * .39;
}
else if ( planet == 3 )
{
newWeight = weight * 2.65;
}
else if ( planet == 4 )
{
newWeight = weight * 1.17;
}
else if ( planet == 5 )
{
newWeight = weight * 1.05;
}
else if ( planet == 6 )
{
newWeight = weight * 1.23;
}
else
{
System.out.println( "error" );
}
System.out.println( "Your weight would be " + newWeight + " pounds on that planet." );
}
}
Picture of the output