Created
November 22, 2023 00:32
-
-
Save rafarocha/b54fa393a2eb57a756669bc1338a92c1 to your computer and use it in GitHub Desktop.
turma-1076-desafio03-feedback-carlos-alberto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
/** | |
* | |
* @author Carlos Alberto Angelo | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("CALCULADORA DE IMC"); | |
System.out.print("Informe a sua altura em metros: "); | |
double altura = sc.nextDouble(); | |
System.out.print("Informe o seu peso em kg: "); | |
double peso = sc.nextDouble(); | |
double imc = peso / (altura * altura); | |
System.out.printf("O valor do seu IMC é %.2f.\n", imc); | |
if (imc < 18.5) { | |
System.out.println("O seu IMC se classifica como Magreza."); | |
} | |
if (imc >= 18.5 && imc < 25) { | |
System.out.println("O seu IMC se classifica como Normal."); | |
} | |
if (imc >= 25 && imc < 30) { | |
System.out.println("O seu IMC se classifica como Sobrepeso."); | |
} | |
if (imc >= 30 && imc < 35) { | |
System.out.println("O seu IMC se classifica como Obesidade grau I."); | |
} | |
if (imc >= 35 && imc < 40) { | |
System.out.println("O seu IMC se classifica como Obesidade grau II."); | |
} | |
if (imc >= 40) { | |
System.out.println("O seu IMC se classifica como Obesidade grau III."); | |
} | |
double pesoIdealMaximo = 24.9 * (altura * altura); | |
System.out.printf("O seu peso ideal seria %.1f kg.\n", pesoIdealMaximo); | |
double pesoIdealMinimo = 18.5 * (altura * altura); | |
System.out.printf("A sua faixa de peso ideal seria entre %.1f kg e %.1f kg.\n", pesoIdealMinimo, pesoIdealMaximo); | |
} | |
} |
Obrigado, Rocha! Perfeito.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revisão
%.1f
Melhorias
NaN e 0.0
Referências