don't understand why we should set up the variable to be 0?
public static void main(String[] args) {
String recipeName, userInputStr;
int userInputInt;
int numberOfServings = 0;
double totalCalories = 0;
double totalFat = 0;
double totalCholesterol = 0;
double totalCarbohydrate = 0;
double totalProtein = 0;
Scanner inputStream = new Scanner(System.in);
System.out.println(" name of this recipe? ");
recipeName = inputStream.nextLine();
System.out.println(" How many servings? ");
userInputStr = inputStream.nextLine();
numberOfServings = Integer.parseInt(userInputStr);
if (numberOfServings < SERVINGS_MIN || numberOfServings > SERVINGS_MAX) {
System.out.println(" Wrong number of servings.");
System.exit(-1);
}
System.out.println("----------List of Possible Ingridients==========");
System.out.println(INDENT + "Food #1: " + FOOD_1_NAME);
System.out.println(INDENT + "Food #2: " + FOOD_2_NAME);
System.out.println(INDENT + "Food #3: " + FOOD_3_NAME);
System.out.println(INDENT + "Food #4: " + FOOD_4_NAME);
System.out.println(INDENT + "Food #5: " + FOOD_5_NAME);
System.out.println(" How many grams of " + FOOD_1_NAME + "? ");
userInputStr = inputStream.nextLine();
userInputInt = Integer.parseInt(userInputStr);
if (userInputInt < GRAMS_MIN || userInputInt > GRAMS_MAX) {
System.out.println(" Wrong number of grams.");
System.exit(-1);
}
totalCalories += userInputInt * (FOOD_1_CALORIES_P100G / 100.);
totalFat += userInputInt * (FOOD_1_FAT_P100G / 100.);
totalCholesterol += userInputInt * (FOOD_1_CHOLESTEROL_P100G / 100.);
totalCarbohydrate += userInputInt * (FOOD_1_CARBOHYDRYTE_P100G / 100.);
totalProtein += userInputInt * (FOOD_1_PROTEIN_P100G / 100.);