Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class IMC{
- public static void main(String[] args){
- Scanner sauron = new Scanner(System.in);
- System.out.println("whats your tweight");
- int age = sauron.nextInt();
- Planeta mars = new Planeta(); //create object Planeta
- mars.nome = "Mars";
- mars.grav = 0.38;
- double marte = mars.peso(age,0.38);
- System.out.println("I have information about the following planets");
- System.out.println("1. Venus \t 2.Mars \t 3.Jupiter");
- System.out.println("4. Saturn \t 5.Uranus \t 6.Neptune");
- System.out.println("Wich planet are you visiting?");
- Scanner answer = new Scanner(System.in);
- int num = answer.nextInt();
- //this is were im lost, no idea of how should i get the info from the user and then display the info of the
- //specific planet
- if(num == 2)
- {
- System.out.println(marte);
- }
- }
- public class Planeta{
- String nome;
- double grav;
- public double peso(int peso, double grav)
- {
- this.grav = grav;
- return peso * grav;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement