BMI Calculator
BMI Calculator
import java.util.Scanner;
String choice;
do {
// Display Heading
System.out.println("\n===============================");
System.out.println("===============================");
double weight = 0;
while (!validWeight) {
try {
weight = scanner.nextDouble();
if (weight <= 0) {
} else {
validWeight = true;
} catch (Exception e) {
}
}
double heightInCm = 0;
while (!validHeight) {
try {
heightInCm = scanner.nextDouble();
if (heightInCm <= 0) {
} else {
validHeight = true;
} catch (Exception e) {
System.out.println("\n===============================");
System.out.println("===============================");
choice = scanner.next().toLowerCase();
System.out.println("\n===============================");
System.out.println("===============================");
scanner.close();
} else {
}
}