I am trying to input an if-statement inside of this for-loop so that whenever the user still has to eat the loop can be redone without having to lose the data already provided.
boolean yes = true;
boolean no = false;
double calorieCount = DCN;
int snackCalories = 300;
int mealCalories = 1100;
double meal = mealCalories;
double snack = snackCalories;
for (int i = 1; calorieCount <= calorieCount; calorieCount--) {
System.out.println("Did you eat? yes or no");
String answer = sc.next();
if(yes == true) { //You did eat
System.out.println("Did you eat a meal(1) or a snack(2)?");
int foodChoice = sc.nextInt();
if(foodChoice == 1) //Meal
System.out.println("Your calories left for the day : " + (calorieCount - meal));
}
int foodChoice = sc.nextInt();
if(foodChoice == 2) {//Snack
calorieCount = calorieCount - snack;
System.out.println("Your calories left for the day : " + (calorieCount - snack));
}
else {
System.out.println("Your calories left for the day : " + calorieCount);
};
else(no == false){
System.out.println(calorieCount);
}
Aucun commentaire:
Enregistrer un commentaire