Assignment #38 and Space Boxing
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Space Boxing
/// File Name: SpaceBoxing.java
/// Date Finished: 10/27/2015/
import java.util.Scanner;
public class SpaceBoxing
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter your current earth weight: ");
double weight = keyboard.nextDouble();
double venus = 0.78;
double mars = 0.39;
double jupiter = 2.65;
double saturn = 1.17;
double uranus = 1.05;
double neptune = 23;
double weight2;
String planeit = "";
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 2.Uranus 3. Neptune ");
System.out.println(" ");
System.out.print("Which planet are you visiting? (Numnber:) ");
int planet = keyboard.nextInt();
if (planet == 1)
{
weight2 = weight * venus;
planeit = "Venus: " + weight2;
}
else if (planet == 2)
{
weight2 = weight * mars;
planeit = "Mars: " + weight2;
}
else if (planet == 3)
{
weight2 = weight * jupiter;
planeit = "Jupiter: " + weight2;
}
else if (planet == 4)
{
weight2 = weight * saturn;
planeit = "Saturn: " + weight2;
}
else if (planet == 5)
{
weight2 = weight * uranus;
planeit = "Uranus: " + weight2;
}
else if (planet == 6)
{
weight2 = weight * neptune;
planeit = "Neptune: " + weight2;
}
else {
System.out.println("Error - try again!");
}
System.out.println( planeit );
}
}
Picture of the output