Assignemnt #38
Code
/// Name: Connor Siri
/// Period: 7
/// Program Name: Space
/// File Name: Space.java
/// Date Finished: 10/5/2015
import java.util.Scanner;
class Space{
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int weight, planet;
double Nweight;
System.out.print("Please enter your current earth weight: ");
weight = keyboard.nextInt();
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.print("Which planet are you visiting? ");
planet = keyboard.nextInt();
if ( planet == 1 )
{
Nweight = ( weight * 0.78 );
}
else if ( planet == 2 )
{
Nweight = ( weight * 0.39 );
}
else if ( planet == 3 )
{
Nweight = ( weight * 2.65 );
}
else if ( planet == 4 )
{
Nweight = ( weight * 1.17 );
}
else if ( planet == 5 )
{
Nweight = ( weight * 1.05 );
}
else if ( planet == 6 )
{
Nweight = ( weight * 1.23 );
}
else
{
Nweight = planet;
}
System.out.println("Your weight would be " + Nweight + " pounds on that planet.");
}
}
Picture of the output