java - While loop help -


i have project class have ask user input body mass index , body surface area calculator. have if else statement need put in while-loop. need have go through , if user enters 'w' bring weight variable , 'h' height. if user enters 'q' quit program. need on how create while loop.

import java.util.*; public class assignment2 {   public static void main(string[] args) {      //scanner     scanner stdin = new scanner(system.in);       //variables     final double meters_to_cm = 100;   // constant convert meters centimeters     final double bsa_constant = 3600;  // constant divide bsa     double bmi;                        // body mass index     double weight;                     // weight in kilograms     double height;                     // height in meters     string classification;             // classifies user bmi categories      double bsa;                        // body surface area     char quit = stdin.nextline().charat(0);      system.out.print("welcome bmi , bsa calculator begin enter weight in kilograms.");     weight = stdin.nextdouble();     system.out.print("enter height in meters: ");     height = stdin.nextdouble();       bmi = weight/(height*height);      while (quit != 'q');     {         if (bmi < 18.5)         {             classification = "underweight";         }         else if (bmi < 25)         {             classification = "normal";         }         else if (bmi < 30)         {             classification = "overweight";         }         else         {             classification = "obese";         }          system.out.println("your classification is: " + classification);          bsa = math.sqrt(((height*meters_to_cm)*weight)/bsa_constant);         system.out.printf("bmi: %.1f\n", bmi);         system.out.printf("bsa: %.2f\n", bsa);     } } } 

here basic logic.

   string inp = ask user input;    while(!inp.equalsignorecase("q")){        if(inp w){         }else{           if(inp h){            }        }        inp = ask user input;    } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -