Assignemnt #38: Space Boxing
Code
/// Name: Kelsey Lieberman
/// Period 5
/// Program Name: SpaceBoxing
/// File Name: SpaceBoxing.java
/// Date Finished: 10/19/2015
import java.util.Scanner;
public class SpaceBoxing
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
double VenusWt, MarsWt, JupiterWt, SaturnWt, UranusWt, NeptuneWt;
int weight;
String planet;
System.out.print("Please enter your current weight on Earth: ");
weight = keyboard.nextInt();
VenusWt = (weight*0.78);
MarsWt = (weight*0.39);
JupiterWt = (weight*2.65);
SaturnWt = (weight*1.17);
UranusWt = (weight*1.05);
NeptuneWt = (weight*1.24);
System.out.println("I have information for the following planets: \n1.) Venus\t2.) Mars\t3.) Jupiter\n4.) Saturn\t5.) Uranus\t6.) Neptune\n");
System.out.print("Which planet are you visiting? ");
planet = keyboard.next();
if (planet.equals("1"))
{
System.out.println("Your weight should be " + VenusWt +" pounds on that planet.");
}
else if (planet.equals("Venus"))
{
System.out.println("Your weight should be " + VenusWt +" pounds on that planet.");
}
else if (planet.equals("2"))
{
System.out.println("Your weight should be " + MarsWt +" pounds on that planet.");
}
else if (planet.equals("Mars"))
{
System.out.println("Your weight should be " + MarsWt +" pounds on that planet.");
}
else if (planet.equals("3"))
{
System.out.println("Your weight should be " + JupiterWt +" pounds on that planet.");
}
else if (planet.equals("Jupiter"))
{
System.out.println("Your weight should be " + JupiterWt +" pounds on that planet.");
}
else if (planet.equals("4"))
{
System.out.println("Your weight should be " + SaturnWt +" pounds on that planet.");
}
else if (planet.equals("Saturn"))
{
System.out.println("Your weight should be " + SaturnWt +" pounds on that planet.");
}
else if (planet.equals("5"))
{
System.out.println("Your weight should be " + UranusWt +" pounds on that planet.");
}
else if (planet.equals("Uranus"))
{
System.out.println("Your weight should be " + UranusWt +" pounds on that planet.");
}
else if (planet.equals("6"))
{
System.out.println("Your weight should be " + NeptuneWt +" pounds on that planet.");
}
else if (planet.equals("Neptune" ))
{
System.out.println("Your weight should be " + NeptuneWt +" pounds on that planet.");
}
else
{
System.out.println("ERROR: Please enter a valid planet from list above.");
}
}
}
Picture of the output