C# Console Calculator about if statement -
i have no idea know what's wrong if statement. program switch off after asked user enter gender. enter 1 if male enter 2 if female
static void main(string[] args) { int waisttoheightcalculatoroption,genderoption; double heightcm = 0.0, waistcm = 0.0; double waisttoheightratio = 0.0; string waisttoheightcalculatormenu = ("which measurement want use enter weight , height?" + "\n1)enter 1 metric" + "\n2)enter 2 british imperial:"); console.write(waisttoheightcalculatormenu); waisttoheightcalculatoroption = int.parse(console.readline()); if (waisttoheightcalculatoroption == 1) { console.write("\nplease enter height in cm:"); heightcm = double.parse(console.readline()); console.write("\nplease enter waist in centimetres (cm):"); waistcm = double.parse(console.readline()); waisttoheightratio = waistcm / heightcm; console.writeline("your waist height ratio {0}", waisttoheightratio); console.write("\n1)enter 1 if male" + "\n2)enter 2 if female:"); genderoption = int.parse(console.readline()); if (genderoption ==1) { if (waisttoheightratio >= 0.536) { console.writeline("your risk of obesity related cardiovascular diseases @ high risk"); } else if (waisttoheightratio < 0.536) { console.writeline("your risk of obesity related cardiovascular diseases @ low risk"); } } else if (genderoption == 2) { if (waisttoheightratio >= 0.492) { console.write("your risk of obesity related cardiovascular diseases @ high risk"); } else if (waisttoheightratio < 0.492) { console.write("your risk of obesity related cardiovascular diseases @ low risk"); } } }
you can press ctr + f5 in visual studio or add console.readkey(); @ end wait user enter key before exit program.
Comments
Post a Comment