Assignemnt #38 and SpaceBoxing
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: Twenty-Seventh Program
/// file name: SpaceBoxing.java
/// date finished: 10/15/15
import java.util.Scanner;
public class SpaceBoxing
{
public static void main(String[] args)
{
int planet;
double weight;
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter your current Earth weight: ");
weight = keyboard.nextDouble();
System.out.println();
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();
System.out.print("What planet will you visit? ");
planet = keyboard.nextInt();
if (planet == 1)
{
weight = weight * 0.78;
}
else if (planet == 2)
{
weight = weight * 0.39;
}
else if (planet == 3)
{
weight = weight * 2.65;
}
else if (planet == 4)
{
weight = weight * 1.17;
}
else if (planet == 5)
{
weight = weight * 1.05;
}
else if (planet == 6)
{
weight = weight * 1.23;
}
else
{
System.out.println("That planet is unknown on our records.");
}
System.out.println();
System.out.println("Your weight would be " + weight + " pounds on that planet.");
}
}
Picture of the output