Assignment #38: Space Boxing
Code
/// Name: Kiran O'Farrell
/// Period: 7
/// Program name: Space Boxing
/// File Name: SpaceBoxing
/// Date Finished: 11/2/15
import java.util.Scanner;
public class SpaceBoxing {
public static void main (String[] args) {
Scanner keyboard = new Scanner(System.in);
int planet;
double weight;
System.out.println("I have information on the following planets:");
System.out.println("1. Venus");
System.out.println("2. Mars");
System.out.println("3. Jupiter");
System.out.println("4. Saturn");
System.out.println("5. Uranus");
System.out.println("6. Neptune");
System.out.println("What is your Earth weight? ");
weight = keyboard.nextDouble();
System.out.println("Which planet are you on? ");
planet = keyboard.nextInt();
if (planet == 1)
{
System.out.println("Your weight would be " + weight * 0.78 + " pounds.");
}
else if (planet == 2)
{
System.out.println("Your weight would be " + weight * 0.39 + " pounds.");
}
else if (planet == 3)
{
System.out.println("Your weight would be " + weight * 2.65 + " pounds.");
}
else if (planet == 4)
{
System.out.println("Your weight would be " + weight * 1.17 + " pounds.");
}
else if (planet == 5)
{
System.out.println("Your weight would be " + weight * 1.05 + " pounds.");
}
else if (planet == 6)
{
System.out.println("Your weight would be " + weight * 1.23 + " pounds.");
}
else
{
System.out.println("I don't have data on that planet.");
}
}
}
Picture of the output