Assignment #38
Code
///jack newsom
///period 5
///program name SpaceBoxing
///filename SpaceBoxing.java
///date completed 9/23/15
import java.util.Scanner;
public class SpaceBoxing
{
public static void main( String[] args)
{
Scanner weightbot = new Scanner(System.in);
double earthWeight, marsWeight, jupiterWeight, saturnWeight, uranusWeight, neptuneWeight, newWeight;
int planetId;
System.out.println("Please enter your current earth weight: ");
earthWeight = weightbot.nextDouble();
System.out.println("I have information for the following planets: ");
System.out.println(" \t1. Venus \t2. Mars \t3. Jupiter");
System.out.println(" \t4. Saturn \t5. Uranus \t6. Neptune");
System.out.println();
System.out.print("Which planet are you visiting?");
planetId = weightbot.nextInt();
if ( planetId == 1 )
{
newWeight = earthWeight * .78;
System.out.println();
System.out.println("Your weight would be " + newWeight + " on that planet.");
}
else if ( planetId == 2 )
{
newWeight = earthWeight * .39;
System.out.println();
System.out.println("Your weight would be " + newWeight + " on that planet.");
}
else if ( planetId == 3 )
{
newWeight = earthWeight * 2.65;
System.out.println();
System.out.println("Your weight would be " + newWeight + " on that planet.");
}
else if ( planetId == 4 )
{
newWeight = earthWeight * 1.17;
System.out.println();
System.out.println("Your weight would be " + newWeight + " on that planet.");
}
else if ( planetId == 5 )
{
newWeight = earthWeight * 1.05;
System.out.println();
System.out.println("Your weight would be " + newWeight + " on that planet.");
}
else if ( planetId == 6 )
{
newWeight = earthWeight * 1.23;
System.out.println();
System.out.println("Your weight would be " + newWeight + " on that planet.");
}
}
}
Picture of the output