Assignemnt #38 Space Boxing

Code

    Name: Iaroslav Titov
    Period: 7
    Project Name: SpaceBoxing
    File Name: SpaceBoxing.java
    Date: 10/2/2015
    
import java.util.Scanner;
import java.util.InputMismatchException;

public class SpaceBoxing
{
    public static void main (String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
        
        float[] coeff = { 0.78f,0.39f,2.65f,1.17f,1.05f,1.23f };
        String[] names = { "Venus","Mars","Jupiter","Saturn","Uranus","Neptune" };
        float weight;
        int chosenPlanet;

        try 
        {
           
            System.out.print( "Enter your current Earth weight: " );
            weight = keyboard.nextFloat();
            System.out.println();
            
            System.out.println("Choose a planet to calculate your weight on: ");
            
            for (int i = 0;i < 6;i++)
            {
                System.out.print("  "+(i+1)+". "+names[i]+"    ");
                if (i==2) System.out.println();
            }
            
            System.out.println();
            
            System.out.print("Enter the number of planet you need: ");
            chosenPlanet = keyboard.nextInt()-1;
            
            weight *= coeff[chosenPlanet];
            System.out.println("Your weight on "+names[chosenPlanet]+" is "+weight+" pounds.");
            
            
        }
        catch (InputMismatchException e)
        {
            System.out.println( "WRONG INPUT!!!" );
        }
        
    }
}

    

Picture of the output

Assignment 35