Question: Could you answer and explain this question? Given main(), complete the Foodltem class (in les Foodltemh and Foodltemcpp) with constructors to initialize each food item.
Could you answer and explain this question?




Given main(), complete the Foodltem class (in les Foodltemh and Foodltemcpp) with constructors to initialize each food item. The default constructor should initialize the name to "None" and all other elds to 0.0. The second constructor should have four parameters (food name, grams of fat, grams of carbohydrates, and grams of protein) and should assign each private eld with the appropriate parameter value Ex: If the input is: M&M's 10.0 34.0 2.0 1.0 where lVl&M's is the food name, 100 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is: Nutritional information per serving of None: Fat: 0.00 g Carbohydrates: 0.00 g Protein: 0.00 g Number of calories for 1.00 serving(s): 0.00 Nutritional information per serving of M&M's: Fat: 10.00 g Carbohydrates: 34.00 g Protein: 2.00 g Number of calories for 1.00 serving(s): 234.00 The rst Foodltem above is initialized using the default constructor. File is marked as read only Current file: main.cpp - 1 #include "FoodItem.h" 2 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
