subject

Given main(), complete the FoodItem class (in files FoodItem. h and FoodItem. cpp) with constructors to initialize each food item. The default constructor should initialize the name to "None" and all other fields 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 field with the appropriate parameter value. Ex: If the input is:

M&M's

10.0

34.0

2.0

1.0

#ifndef FOODITEMH
#define FOODITEMH

#include

using namespace std;

class FoodItem {
public:
// TODO: Declare default constructor

// TODO: Declare second constructor with arguments
// to initialize private data members

string GetName();

double GetFat();

double GetCarbs();

double GetProtein();

double GetCalories(double numServings);

void PrintInfo();

private:
string name;
double fat;
double carbs;
double protein;
};

#endif

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:00
Perform the following tasks: a. create a class named testclass that holds a single private integer field and a public constructor. the only statement in the constructor is one that displays the message “constructing”. write a main()function that instantiates one object of the testclass. save the file as testclass.cpp in the chapter 08 folder. run the program and observe the results. b. write another main()function that instantiates an array of 10 testclass objects. save the file as test class array.c . run this program and observe the results.
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
To produce a starlight effect in her photograph, lina should choose the filter for her camera.
Answers: 1
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Norder to receive financial aid at his vocational school, mario must fill out the fafsa. the fafsa is a form that must be completed to determine . in order to complete a fafsa, you must submit . the fafsa can students obtain
Answers: 2
You know the right answer?
Given main(), complete the FoodItem class (in files FoodItem. h and FoodItem. cpp) with constructors...
Questions
question
Mathematics, 20.06.2020 06:57
question
Mathematics, 20.06.2020 06:57
question
Mathematics, 20.06.2020 06:57
question
Mathematics, 20.06.2020 06:57
question
Mathematics, 20.06.2020 06:57
question
Mathematics, 20.06.2020 06:57
Questions on the website: 13722360