private static final double BMR = 0;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("What is your gender?(M or F)");//Gender
char gender = sc.next().charAt(0);
System.out.println("Your weight in pounds?");//Weight
double weight = sc.nextDouble();
System.out.println("Your height in inches?");//Height
double height = sc.nextDouble();
System.out.println("Your age in years?");//Age
int age = sc.nextInt();
System.out.println("Your BMR is:");//BMR Calculation
double BMR = 0;
if (gender == ('M')){
BMR = 665+(6.23 * weight)+(12.7 * height)-(6.8 * age);
System.out.println(BMR);
} else if (gender == ('F')) {
BMR = 655+(4.35 * weight)+(4.7 * height)-(4.7 * age);
System.out.println(BMR);
}
System.out.println("What is your exercise routine on the scale of 0 to 4? (0 is lowest and 4 is highest) ");//Exercise Calculation
int exercise = sc.nextInt();
System.out.println("Your daily caloric needs is: ");//Daily Caloric Need
double DCN = 0;
if (exercise == 0) {
DCN = (BMR * 1.2);
System.out.println(DCN);
} else if (exercise == 1) {
DCN = (BMR * 1.375);
System.out.println(DCN);
} else if (exercise == 2) {
DCN = (BMR * 1.55);
System.out.println(DCN);
} else if (exercise == 3) {
DCN = (BMR * 1.725);
System.out.println(DCN);
}else if (exercise == 4) {
DCN = (BMR * 1.9);
System.out.println(DCN);
}
Я сделал большую часть того, что было необходимо для l oop, однако у меня возникли трудности при попытке создать do-while l oop. Исходя из приведенного ниже кода, я пытаюсь создать al oop, чтобы показать, сколько калорий осталось на день, когда пользователь вводит, едят ли они еду или закуски, по одному за раз. Наряду с этим, я не могу отобразить доступные калории на день в виде кода автоматически.
//Create a Loop that enables the user to input values for all meals and snack, ONE AT A TIME.
//At the same time the meal or snack entered, the program should display the calories left for the day
//Gender, daily calorie needed, age, height, weight, exercise level, BMR, snack or meal calories
//do input userHeight,Weight,Age,Gender
//calculate userBMR
//Ask for meals taken calories (userSnackCalories)
//more initialized to true
//double calorieCount = calorieNeeds;
//UPDATE - calorieCOunt = calorieCount - snack;
//More snacks? yes or no
//yes - get calorie
//no - display
//double caloriesCount = calorieNeeds - snackCalories();
//double caloriesCount = caloriesCount - snackCalories();
//do (//update caloriesCount ){
//}while (more snacks/Meals in logical expression) {
//more snacks yes or no
double snackCalories = 300;
double mealCalories = 1100;
do {
System.out.println("Your Daily calories left " + ());
}
while (yes && no) {
}
}
}