Assignment # 38 and Space Boxing
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: SpaceBoxing
/// File Name: SpaceBoxing.java
/// Date: 11/2/2015
import java.util.Scanner;
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;
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.");
}
}
Picture of the output