Advertisement
Nannoka

Peso ideal

Aug 8th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Principal {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         System.out.println("Digite f para feminino e m para masculino: ");
  10.  
  11.         String sexo = scanner.nextLine();
  12.  
  13.         System.out.println("Digite seu altura: ");
  14.  
  15.         double alt = scanner.nextDouble();
  16.  
  17.         double ideal = PesoIdeal.PesoIdeal(sexo, alt);
  18.        
  19.         System.out.println("Seu peso ideal é: " + ideal);
  20.     }
  21. }
  22.  
  23.  
  24.  // classe para calculo:
  25.  
  26.  
  27. public class PesoIdeal {
  28.  
  29.     public static double PesoIdeal(String sexo, double alt) {
  30.         if (sexo.charAt(0) == 'm') {
  31.             return ((72.7 * alt) - 58);
  32.         } else if (sexo.charAt(0) == 'f') {
  33.             return ((62.1 * alt) - 44.7);
  34.         } else
  35.             return 0;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement