I really really need to get this done urgently. I'm trying to do an agent based model on plants and humans on a spaceship here's the code:
here's the header file:Code://preprocessor directives #include "supercomputingMath.h" //plant structs struct Plant soybeans; struct Plant potatoes; struct Plant tomatoes; struct Plant strawberries; //human structs struct Human dhaivat; struct Human colin; struct Human matthew; struct Human michael; struct Human mrscooper; int isAlive; //define globals long time; //the amount of oxygen will be 20% of the spaceship size int spaceShipSize; int oxygenInSpaceShip; int CO2InSpaceShip; //number of plants int amountOfPlants; int amountOfSoybeans; int amountOfPotatoes; int amountOfTomatoes; int amountOfStrawberries; int counterForPlants; int counterForPlants2; int caloriesForTheDay; //initialize the structs and other variables static void initVariables(){ soybeans.foodDays=60; soybeans.maxAge=60; soybeans.CO2UsedPerDay=1; soybeans.caloriesPerDay=200; potatoes.foodDays=45; potatoes.maxAge=45; potatoes.CO2UsedPerDay=1; potatoes.caloriesPerDay=30; tomatoes.foodDays=60; tomatoes.maxAge=180; tomatoes.CO2UsedPerDay=2; tomatoes.caloriesPerDay=45; strawberries.foodDays=0; strawberries.maxAge=90; strawberries.CO2UsedPerDay=1.0; strawberries.caloriesPerDay=0.4; int time=0; } //main function int main (void) { initVariables(); //get spaceship size printf("Please enter the size of the spaceship (any units, 20 percent of it will be oxygen):"); scanf("%ld",&spaceShipSize); oxygenInSpaceShip=spaceShipSize*0.2; printf("Please enter the number of plants :"); scanf("%i", &amountOfPlants); timer(); isItHarvestTime(time); //run functions oxygenAbsorbedByHumans(time); carbonDioxideReleasedByHumans(time); return 0; } //a function to keep time by hours long timer(void) { time++; caloriesForTheDay=0; return time; } //a function that keeps track of the oxygen the humans are able to absorb void oxygenAbsorbedByHumans (long currentDay) { if(isHumanAlive(dhaivat.oxygenAbsorbedForHuman)==1 && oxygenInSpaceShip-dhaivat.oxygenAbsorbedForHuman>0) dhaivat.oxygenAbsorbedForHuman=currentDay*120*24; else { printf("Dhaivat is dead"); } if(isHumanAlive(colin.oxygenAbsorbedForHuman)==1 && oxygenInSpaceShip-colin.oxygenAbsorbedForHuman>0 ) colin.oxygenAbsorbedForHuman=currentDay*120*24; else { printf("Colin is dead"); } if(isHumanAlive(matthew.oxygenAbsorbedForHuman)==1 && oxygenInSpaceShip-matthew.oxygenAbsorbedForHuman>0) matthew.oxygenAbsorbedForHuman=currentDay*120*24; else { printf("Matthew is dead"); } if(isHumanAlive(michael.oxygenAbsorbedForHuman)==1 && oxygenInSpaceShip-michael.oxygenAbsorbedForHuman>0) michael.oxygenAbsorbedForHuman=currentDay*120*24; else { printf("Michael is dead"); } if(isHumanAlive(mrscooper.oxygenAbsorbedForHuman)==1 && oxygenInSpaceShip-mrscooper.oxygenAbsorbedForHuman>0) mrscooper.oxygenAbsorbedForHuman=currentDay*120*24; printf("Day %ld: \n", currentDay); printf("Dhaivat has absorbed %d units of oxygen. \n", dhaivat.oxygenAbsorbedForHuman); printf("Colin has absorbed %d units of oxygen. \n", colin.oxygenAbsorbedForHuman); printf("Matthew has absorbed %d units of oxygen. \n", matthew.oxygenAbsorbedForHuman); printf("Michael has absorbed %d units of oxygen. \n", michael.oxygenAbsorbedForHuman); } //keeps track of the carbon dioxide released by each human void carbonDioxideReleasedByHumans(long currentDay) { dhaivat.carbonDioxideReleasedForHuman=currentDay*35.52*24; colin.carbonDioxideReleasedForHuman=currentDay*35.52*24; matthew.carbonDioxideReleasedForHuman=currentDay*35.52*24; michael.carbonDioxideReleasedForHuman=currentDay*35.52*24; mrscooper.carbonDioxideReleasedForHuman=currentDay*35.52*24; } //find out which humans are alive and which ones are dead. int isHumanAlive(int oxygenAbsorbedForHuman) { if(oxygenAbsorbedForHuman<2880) { isAlive=0; return isAlive; } else { isAlive=1; return isAlive; } } void setAmountOfPlants(int amountOfPlants) { //amountOfPlants = 2500+(100*counterForPlants); amountOfSoybeans=amountOfPlants*0.40; amountOfPotatoes=amountOfPlants*0.15; amountOfTomatoes=amountOfPlants*0.15; amountOfStrawberries=amountOfPlants*0.15; } void isItHarvestTime (long currentDay) { if(currentDay%60==0 && soybeans.isItAlive==1) { caloriesForTheDay=caloriesForTheDay+200*amountOfSoybeans; } if(currentDay%45==0 && potatoes.isItAlive==1) { caloriesForTheDay=caloriesForTheDay+30*amountOfSoybeans; } if(currentDay%1==0 && currentDay!=90 && strawberries.isItAlive==1) { caloriesForTheDay=caloriesForTheDay+0.4*amountOfStrawBerries } else { if(currentDay==90) { strawberries.isItAlive=0; } else { } } }
But when I compile it, its giving me the following error:Code:struct Human{ int oxygenAbsorbedForHuman; int carbonDioxideReleasedForHuman; int isAlive; }; struct Plant{ int foodDays; int maxAge; int caloriesPerDay; int CO2UsedPerDay; int isItAlive; }; struct Plant soybeans; struct Plant potatoes; struct Plant tomatoes; struct Plant strawberries; //define globals int time=-1; //the amount of oxygen will be 20% of the spaceship size int spaceShipSize; int oxygenInSpaceShip; //define struct variables struct Human dhaivat; struct Human colin; struct Human matthew; struct Human michael; struct Human mrscooper; //number of plants int amountOfPlants; int amountOfSoybeans; int amountOfPotatoes; int amountOfTomatoes; int amountOfStrawberries; int counterForPlants; int counterForPlants2; //prototype functions int timer(void); void oxygenAbsorbedByHumans (long currentDay); int isHumanAlive(struct Human someHuman); void carbonDioxideReleasedByHumans(long currentDay); void setAmountOfPlants(int amountOfPlants); void isItHarvestTime(long currentDay);
154: structure has no member named "isItAlive"
157: (as above)
160: (as above)
165: (as above )



LinkBack URL
About LinkBacks



