Assignemnt #38: Differentials of Planetary Weights
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: Different Planetary Weights
/// File Name: SpaceBoxer.java
/// Date Finished: 10/8/2015
import java.util.Scanner;
public class SpaceBoxer
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int weight, PlanetX, X;
double Planet1, Planet2, Planet3, Planet4, Planet5, Planet6;
System.out.println( "Please enter your current Earth weight: " );
weight = keyboard.nextInt();
X = 1;
Planet1 = .78 * weight;
Planet2 = .39 * weight;
Planet3 = 2.65 * weight;
Planet4 = 1.17 * weight;
Planet5 = 1.05 * weight;
Planet6 = 1.23 * weight;
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( "Which planet are you visiting? " );
PlanetX = keyboard.nextInt();
if ( PlanetX == 1 )
{
System.out.println( "Your weight would be " + Planet1 + "pounds on that planet. " );
}
else if (PlanetX == 2 )
{
System.out.println( "Your weight would be " + Planet2 + "pounds on that planet. " );
}
else if ( PlanetX == 3 )
{
System.out.println( "Your weight would be " + Planet3 + "pounds on that planet. " );
}
else if ( PlanetX == 4 )
{
System.out.println( "Your weight would be " + Planet4 + "pounds on that planet. " );
}
else if ( PlanetX == 5 )
{
System.out.println( "Your weight would be " + Planet5 + "pounds on that planet. " );
}
else if ( PlanetX == 6 )
{
System.out.println( "Your weight would be " + Planet6 + "pounds on that planet. " );
}
}
}
Picture of the output