cLass lunch
{
private:
float cost;
int calories;
public:
lunch ();
void set cost (float c);
void set calories (int c);
};
luncn: :lunch ()
{
cost =0.0;
calories =0;
}
void : :lunchdisplay()
{
cout <<"lunch costs"<<cost<<endl;
cout<<"it has"<<calories<<"calories<<"calories"<<endl;
}
void: :lunch: :setcost (float c)
{
cost += c;
}
void lunch: :set calories (int c)
{
calories += c;
}
Recommended Answers
Jump to PostNice code you posted -- why did you post it ? (my crystle ball is broken tonight)
Jump to PostI want the user to enter as many food items as they wish.When the user is done entering food items ,display the total number of food items,the total cost of thelunch and the total number of calories .
Ok, so what doesn't your program do that it should do? What …
All 6 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
jdphenix
0
Newbie Poster
ampdoc
-2
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
ampdoc
-2
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.