Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++: Could you help me with this problem. 1 #include FoodItem.h N #include #include A W using namespace std; 6 7 // Define default constructor

C++: Could you help me with this problem.

image text in transcribedimage text in transcribedimage text in transcribed
1 #include "FoodItem.h" N #include #include A W using namespace std; 6 7 // Define default constructor 8 9 / / Define second constructor with arguments 10 // to initialize private data members 11 12 string FoodItem: : GetName ( ) { 13 return name; 14 } 15 16 double FoodItem: : GetFat( ) { 17 return fat; 18 } 19 20 double FoodItem: : GetCarbs() { 21 return carbs; 22 } 23 24 double FoodItem: : GetProtein() { 25 return protein; 26 } 27 28 double FoodItem: : GetCalories (double numServings) { 29 // Calorie formula 30 double calories = ((fat * 9) + (carbs * 4) + (protein * 4) ) * numServings; 31 return calories; 32 } 33 34 void FoodItem: : PrintInfo( ) { 35 cout 6 using namespace std; J 8 class FoodItem { 9 public: 10 // TODO: Declare default constructor 11 12 // TODO: Declare second constructor with arguments 13 // to initialize private data members 14 15 string GetName ( ) ; 16 17 double GetFat( ) ; 18 19 double GetCarbs( ) ; 20 21 double GetProtein( ) ; 22 23 double GetCalories (double numServings) ; 24 25 void PrintInfo( ) ; 26 27 private : 28 string name; 29 double fat; 30 double carbs; 31 double protein; 32 }; 33 34 #endif

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions