Assignemnt #38 and Space Boxing
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: Space Boxing
/// File Name: SpaceWeight.java
/// Date Finished: 10/29/2015
import java.util.Scanner;
public class SpaceWeight
{
public static void main( String[] args )
{
int weight, planet;
Double weight1, weight2, weight3, weight4, weight5, weight6;
Scanner Keyboard = new Scanner(System.in);
System.out.print( "What is your weight on Earth? ");
weight = Keyboard.nextInt();
System.out.println( "I can give you your weight on 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.println( "What number planet are you visiting? ");
planet = Keyboard.nextInt();
System.out.println();
weight1 = (weight * 0.78);
weight2 = (weight * 0.39);
weight3 = (weight * 2.65);
weight4 = (weight * 1.17);
weight5 = (weight * 1.05);
weight6 = (weight * 1.23);
if ( planet == 1 )
{
System.out.println( "Your weight would be " + weight1 + "." );
}
if ( planet == 2 )
{
System.out.println( "Your weight would be " + weight2 + "." );
}
if ( planet == 3 )
{
System.out.println( "Your weight would be " + weight3 + "." );
}
if ( planet == 4 )
{
System.out.println( "Your weight would be " + weight4 + "." );
}
if ( planet == 5 )
{
System.out.println( "Your weight would be " + weight5 + "." );
}
if ( planet == 6 )
{
System.out.println( "Your weight would be " + weight6 + "." );
}
}
}
Picture of the output