Created
November 22, 2023 12:02
-
-
Save rafarocha/824f376e8965001729116c4c8b0cfc20 to your computer and use it in GitHub Desktop.
turma-1076-desafio03-feedback-deyse-ribeiro.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; | |
import java.lang.Math; | |
public class Main { | |
public static void main(String[] args) { | |
//Variaveis | |
Scanner entrada = new Scanner(System.in); | |
float altura; | |
float peso; | |
double imc; | |
double peso_ideal; | |
double imc_ideal_min = 18.5; | |
double imc_ideal_max = 24.9; | |
double peso_min; | |
double peso_max; | |
//Coletando dados | |
System.out.println("Calculadora de IMC"); | |
System.out.println(">Insira sua altura(cm):"); | |
System.out.print(">"); | |
altura = entrada.nextFloat(); | |
System.out.println(">Insira seu peso(Kg):"); | |
System.out.print(">"); | |
//Calculando | |
peso = entrada.nextFloat(); | |
imc = Math.round(peso*100000/(altura*altura)); | |
imc = imc/10; | |
peso_ideal=Math.round(altura*altura*imc_ideal_min/10000); | |
peso_min=peso_ideal; | |
peso_max=Math.round(altura*altura*imc_ideal_max/10000); | |
//Resultados | |
System.out.println("<<<Resultados>>>"); | |
System.out.println(">O imc é:"+imc); | |
if(imc < 18.5){ | |
System.out.println(">Magreza"); | |
} | |
if(imc >= 18.5 && imc <= 24.9){ | |
System.out.println(">Normal"); | |
} | |
if(imc >= 25 && imc <= 29.9){ | |
System.out.println(">Sobrepeso"); | |
} | |
if(imc>= 30 && imc <= 34.9){ | |
System.out.println(">Obesidade Grau I"); | |
} | |
if(imc >= 35 && imc <= 39.9){ | |
System.out.println(">Obesidade Grau II"); | |
} | |
if(imc > 40){ | |
System.out.println(">Obesidade Grau III"); | |
} | |
System.out.println(">O peso ideal é:"+peso_max+"Kg"); | |
System.out.println(">A faixa de peso ideal é entre: "+peso_min+"Kg e "+peso_max+"Kg"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revisão
Melhorias
else if
ao invés de vários ifs independentes com&&
0.0 e Magreza
Referências