Hello Everyone,
program in total adds the number of calories multiplied by number of donuts which is wrong, I'm trying to make it display the total number of calories by adding the total calories of order 1, 2 and 3, any suggestions?
#include <iostream>
using namespace std;
class Donut
{
private:
string type;
int quantity;
int numOfCalories;
public:
cout << "Order1: " << endl;
cout <<"Enter type of Donut(jelly filled, sprinkles, cruller, chocolate, boston-cream),";
cout <<"quantity, and number of calories in each donut: "<<endl;
cin >> order1;
cout << "Order2: " << endl;
cout <<"Enter type of Donut(jelly filled, sprinkles, cruller, chocolate, boston-cream),";
cout <<"quantity, and number of calories in each donut: "<<endl;
cin >> order2;
cout << "Order3: " << endl;
cout <<"Enter type of Donut(jelly filled, sprinkles, cruller, chocolate, boston-cream),";
cout <<"quantity, and number of calories in each donut: "<<endl;
cin >> order3;
However, you now have a discrepancy in how you're representing calories. Using the constructor, numOfCalories represents the number of calories of a single donut. But after doing the above calculation, numOfCalories now represents the total number of calories for all donuts. That's not the same thing as your original representation.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.