Advertisement
Guest User

Untitled

a guest
Feb 9th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. public class IMC{
  2. public static void main(String[] args){
  3.  
  4.  Scanner sauron = new Scanner(System.in);
  5.  System.out.println("whats your tweight");
  6.  int age = sauron.nextInt();
  7.  Planeta mars = new Planeta(); //create object Planeta
  8.  mars.nome = "Mars";
  9.  mars.grav = 0.38;
  10.  double marte = mars.peso(age,0.38);
  11.  System.out.println("I have information about the following planets");
  12.  System.out.println("1. Venus \t 2.Mars \t 3.Jupiter");
  13.  System.out.println("4. Saturn \t 5.Uranus \t 6.Neptune");
  14.  System.out.println("Wich planet are you visiting?");
  15.  Scanner answer = new Scanner(System.in);
  16.  int num = answer.nextInt();
  17.  
  18.  
  19. //this is were im lost, no idea of how should i get the info from the user and then display the info of the
  20. //specific planet
  21.  if(num == 2)
  22.  {
  23.  System.out.println(marte);
  24.  }
  25.  
  26.  
  27.  }
  28.  
  29.  
  30. public class Planeta{
  31. String nome;
  32. double grav;
  33.  
  34. public double peso(int peso, double grav)
  35. {
  36. this.grav = grav;
  37. return peso * grav;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement