Computing Functions

I need to compute the total food (pounds per week) requirements for each TYPE of McDonalds in a local area. The Types of McDonalds range 1-10. They're are represented as McDonalds[].Type. The other column in the data file is pounds per week.

How do I compute the total food per week of each TYPE of McDonalds

Here is a data list

1 200
1 150
1 175
2 153
3 167
3 189
4 250
5 225
6 89
6 109
7 167
8 145
9 199
10 230
10 220


#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

using namespace std;

#define DATA_FILE "./McDonalds"
#define SUCCESS 0
#define FAIL 1

class McDonalds
{
public:
void load_data();
//loads data from DATA_FILE into array
int total_food_by_type();
//computes total food requirements for each TYPE of McDonalds
private:
struct McInfo
{
int type;
//McDonald Type
int pounds;
//McDonald FOOD
};
};

int main ()
{
ifstream in_data1;
string line;
int size;
McInfo *McArr;
McDonalds information;

information.load_data1();
information.total_food_by_type();

in_data2.close();
delete [] McArr;
}

void McDonalds::load_data1();
{
string line;
int size = 0;

in_data1.open(DATA_FILE);
if(in_data1.fail())
{
cout<<"cannot open instream input file\n\n";
return(FAIL);
}

while(getline(in_data1, line)) size++;

in_data1.close();
in_data1.open(DATA_FILE);

McInfo *McArr = new McInfo[size];

for(int i = 0; i < size; i++)
{
in_data1>>McArr[i].type;
in_data1>>McArr[i].pounds;
}
}

int McDonalds::total_food_by_type();
{
//this is where it confuses me

return( );
}
Topic archived. No new replies allowed.