Julio Cesar Chavez Mark VII is an interplanetary space boxer, who currently holds the championship belts for various weight categories on many different planets within our solar system. However, it is often difficult for him to recall what his "target weight" needs to be on earth to make the weight class on other planets. Write a Java program to help him keep track of this. Create a Weight class in which you will have your main method. Perform all the inputs, calculations, and outputs in the main method.
It should ask him what his earth weight is, and to enter a number for the planet he wants to fight on. It should then compute his weight on the destination planet based on the table below:
#
Planet
Relative gravity
1. Venus: 0.78
2. Mars: 0.39
3. Jupiter: 2.65
4. Saturn: 1.17
5. Uranus: 1.05
6.Neptune: 1.23
information for the following planets:
1. Venus 2. Mars 3. Jupiter
4. Saturn 5. Uranus 6. Neptune
Which planet are you visiting?
import java.util.Scanner;
public class Weight {
public static void main(String[] args) {
System.out.println("You can choose:\n1.Venus 2.Mars 3.Jupiter\n" + "4.Saturn 5.Uranus 6.Neptune");
Scanner number = new Scanner(System.in);
System.out.print("Enter the planet: ");
int plNumb = number.nextInt();
System.out.print("Enter your weight: ");
int weight = number.nextInt();
switch(plNumb){
case 1:
double VeneraWeight=weight* 0.78;
System.out.println(VeneraWeight);
break;
case 2:
double MarsWeight=weight*0.39;
System.out.println(MarsWeight);
break;
case 3:
double JupiterWeight=weight*2.65;
System.out.println(JupiterWeight);
break;
case 4:
double SaturnWeight=weight*1.17;
System.out.println(SaturnWeight);
break;
case 5:
double UranusWeight=weight*1.05;
System.out.println(UranusWeight);
break;
case 6:
double NeptunWeight=weight*1.23;
System.out.println(NeptunWeight);
break;
default:
break;
}
}
}
Comments
Leave a comment