Now, I am sure there are more than 3 problems with this thing, and it's been sort of butchered into pieces with me attempting to solve this issue. Regardless, outside of the three problems I'd appreciate any input.
My book tasks me with creating a program for a zoo that allows them to keep track of how much food (in terms of weight) three of their monkeys ate, and then performs some calculations on those numbers.
The compiler is reporting 3 errors, on lines 118, 119 and 120.
each line has the same error "expected primary expression before 'Travis'", the only thing that changes is what it expects the expression before, on line 119 it's beat and on line 120 it's Ryo.
#include <iostream>
using namespace std;
class Monkey
{
int ryosmall, beatsmall, travissmall;
public:
int eats[7];
bool checkValid(int);
int travissmallest(Monkey, int);
int beatsmallest(Monkey, int);
int ryosmallest(Monkey, int);
int getTravis() { return travissmall; }
int getBeat() { return beatsmall; }
int getRyo() { return ryosmall; }
//int leastAmount(Monkey, Monkey, Monkey);
int total(Monkey, Monkey, Monkey);
int average(Monkey, Monkey, Monkey);
};
bool Monkey::checkValid(int temp)
{
if (temp <= 0)
return false;
else
return true;
}
int Monkey::travissmallest(Monkey Travis, int travissmall)
{
//static int monkey[3] = {9999, 9999, 9999};
travissmall = 90000;
for (int i = 0; i < 7; i++)
{
if (Travis.eats[i] < travissmall)
{
travissmall = Travis.eats[i];
}
} return travissmall;
}
int Monkey::beatsmallest(Monkey Beat, int beatsmall)
{
beatsmall = 90000;
for (int i = 0; i < 7; i++)
{
if (Beat.eats[i] < beatsmall)
{ beatsmall = Beat.eats[i]; }
} return beatsmall;
}
int Monkey::ryosmallest(Monkey Ryo, int Ryosmall)
{
ryosmall = 90000;
for (int i = 0; i < 7; i++)
{
if (Ryo.eats[i] < ryosmall)
{ ryosmall = Ryo.eats[i]; }
} return ryosmall;
}
int Monkey::total(Monkey Travis, Monkey Beat, Monkey Ryo)
{
static int eachdaytot[7];
for (int i = 0; i < 7; i++)
{ eachdaytot[i] = Travis.eats[i] + Beat.eats[i] + Ryo.eats[i]; };
return *eachdaytot;
}
int Monkey::average(Monkey Travis, Monkey Beat, Monkey Ryo)
{
static int eachdayavg[7];
for (int i = 0; i < 7; i++)
{ eachdayavg[i] = Travis.eats[i] + Beat.eats[i] + Ryo.eats[i] / 3; };
return *eachdayavg;
}
int main()
{
int temp;
Monkey Travis, Beat, Ryo, general;
cout << "What was the least amount of food (pints) eaten by Travis this week?" << endl;
for (int i = 0; i < 7; i++)
{
cin >> temp;
if (Travis.checkValid(temp) == true)
{ Travis.eats[i] = temp; }
else
{ i -= 1; }
}
cout << "What was the least amount of food (pints) eaten by Beat this week?" << endl;
for (int i = 0; i < 7; i++)
{
cin >> temp;
if (Beat.checkValid(temp) == true)
{ Beat.eats[i] = temp; }
else
{ i -= 1; }
}
cout << "What was the least amount of food (pints) eaten by Ryo this week?" << endl;
for (int i = 0; i < 7; i++)
{
cin >> temp;
if (Ryo.checkValid(temp) == true)
{ Ryo.eats[i] = temp; }
else
{ i -= 1; }
};
general.travissmallest(Monkey Travis);
general.beatsmallest(Monkey Beat);
general.ryosmallest(Monkey Ryo);
cout << "Travis' smallest meal was " << general.getTravis() << cout << " Beat's was " << general.getBeat()
<< " Ryo's was " << general.getRyo() << endl;
for (int i = 0; i < 7; i++)
{ cout << "The total food eaten this day by the group " << general.total (Travis, Beat, Ryo) << endl; }
for (int i = 0; i < 7; i++)
{ cout << "The average food eaten this day by the group " << general.average (Travis, Beat, Ryo) << endl; }
};