Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Could you answer and explain the following question? Given main(), complete the Foodltem class (in les Foodltemh and Foodltemcpp) with constructors to initialize each food
Could you answer and explain the following 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 #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started