Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Principal {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Digite f para feminino e m para masculino: ");
- String sexo = scanner.nextLine();
- System.out.println("Digite seu altura: ");
- double alt = scanner.nextDouble();
- double ideal = PesoIdeal.PesoIdeal(sexo, alt);
- System.out.println("Seu peso ideal é: " + ideal);
- }
- }
- // classe para calculo:
- public class PesoIdeal {
- public static double PesoIdeal(String sexo, double alt) {
- if (sexo.charAt(0) == 'm') {
- return ((72.7 * alt) - 58);
- } else if (sexo.charAt(0) == 'f') {
- return ((62.1 * alt) - 44.7);
- } else
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement