1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
#include <iostream>
using namespace std;
float ab, ad, yb, yd, fb, fd, x, f;
int year = 1;
int abht, adht, nabht, nadht, fbht, fdht, nfbht, nfdht, check, check1, check2, check3, fcheck, population, spopulation;
void getinfo();
void upyear();
void huntingtags();
void round();
int main()
{
getinfo();
cin.ignore();
while(year <= 20)
{
while(population < 1000)
{
upyear();
}
while(population >= 1000)
{
huntingtags();
upyear();
if( population >= 1500)
{
cout << "Population exceeded 1500. Population was: " << population << ".\n";
cin.ignore();
return 0;
}
}
if(year == 20 && 1500 < population > 1450)
{
cout << "Population: " << population << ".\n";
cin.ignore();
return 0;
}
if(year == 20 && population > 1450)
{
cout << "Population did not reach 1450. Population was: " << population << ".\n";
cin.ignore();
return 0;
}
}
return 0;
}
void getinfo()
{
cout << "How many adult bucks do you have?\n";
cin >> ab;
cin.ignore();
system("cls");
cout << "How many adult does do you have?\n";
cin >> ad;
cin.ignore();
system("cls");
cout << "How many yearling bucks do you have?\n";
cin >> yb;
cin.ignore();
system("cls");
cout << "How many yearling does do you have?\n";
cin >> yd;
cin.ignore();
system("cls");
cout << "How many fawn bucks do you have?\n";
cin >> fb;
cin.ignore();
system("cls");
cout << "How many fawn does do you have?\n";
cin >> fd;
cin.ignore();
system("cls");
cout << "You have " << ab << " adult bucks.\n";
cout << "You have " << ad << " adult does.\n";
cout << "You have " << yb << " yearling bucks.\n";
cout << "You have " << yd << " yearling does.\n";
cout << "You have " << fb << " fawn bucks.\n";
cout << "You have " << fd << " fawn doe.\n";
population = ab + ad + yb + yd + fb + fd;
cout << "You have " << population << " total dear.\n";
}
void upyear()
{
ab = ab + yb;
ad = ad + yd;
yb = fb;
yd = fd;
if(ab >= ad)
{
fb = ad/2;
fd = ad/2;
}
if(ab < ad)
{
if(2*ab >= ad)
{
fb = ad/2;
fd = ad/2;
}
if(2*ab < ad)
{
fb = ad;
fd = ad;
}
}
if(fb - fd == 0 && fcheck == 0)
{
fd = ceil(fd);
fb = floor(fb);
fcheck = 1;
}
if(fb - fd == 0 && fcheck == 1)
{
fb = ceil(fb);
fd = floor(fd);
fcheck = 0;
}
cout << "Year " << year << ":\n";
cout << "Adult Bucks - " << ab << '\n';
cout << "Adult Does - " << ad << '\n';
cout << "Yearling Bucks - " << yb << '\n';
cout << "Yearling Does - " << yd << '\n';
cout << "Fawn Bucks - " << fb << '\n';
cout << "Fawn Does - " << fd << '\n';
population = ab + ad + yb + yd + fb + fd;
cout << "Population - " << population << "\n\n";
ab = ab*0.95;
x = ab;
round();
ab = x;
ad = ad*0.95;
x = ad;
round();
ad = x;
yb = yb*0.85;
x = yb;
round();
yb = x;
yd = yd*0.85;
x = yd;
round();
yd = x;
fb = fb*0.7;
x = fb;
round();
fb = x;
fd = fd*0.7;
x = fd;
round();
fd = x;
cout << "Year " << year << " with survival rates:\n";
cout << "Adult Bucks - " << ab << '\n';
cout << "Adult Does - " << ad << '\n';
cout << "Yearling Bucks - " << yb << '\n';
cout << "Yearling Does - " << yd << '\n';
cout << "Fawn Bucks - " << fb << '\n';
cout << "Fawn Does - " << fd << '\n';
spopulation = ab + ad + yb + yd + fb + fd;
cout << "Population - " << spopulation << "\n\n";
year = year + 1;
}
void huntingtags()
{
while(check == 0)
{
cout << "How many adult buck hunting tags do you want?\n";
cin >> abht;
cin.ignore();
cout << "How many adult doe hunting tags do you want?\n";
cin >> adht;
cin.ignore();
cout << "How many fawn buck hunting tags do you want?\n";
cin >> fbht;
cin.ignore();
cout << "How many fawn doe hunting tags do you want?\n";
cin >> fdht;
cin.ignore();
cout << '\n';
check = 1;
}
while(check == 1 && check2 == 1)
{
while(check3 == 0)
{
check1 = 1;
cout << "How many adult buck hunting tags do you want?\n";
cin >> nabht;
cin.ignore();
cout << "How many adult doe hunting tags do you want?\n";
cin >> nadht;
cin.ignore();
cout << "How many fawn buck hunting tags do you want?\n";
cin >> nfbht;
cin.ignore();
cout << "How many fawn doe hunting tags do you want?\n";
cin >> nfdht;
cin.ignore();
cout << '\n';
if(nabht-abht >= 6)
{
cout << "\nYour new hunting tag amount cannot be 5 more or 5 less than the amount you\ndid last year.\nLast year you had: " << abht << " adult buck hunting tags.\n";
}
if(nadht-adht >= 6)
{
cout << "\nYour new hunting tag amount cannot be 5 more or 5 less than the amount you\ndid last year.\nLast year you had: " << adht << " adult doe hunting tags.\n";
}
if(nfbht-fbht >= 6)
{
cout << "\nYour new hunting tag amount cannot be 5 more or 5 less than the amount you\ndid last year.\nLast year you had: " << fbht << " fawn buck hunting tags.\n";
}
if(nfdht-fdht >= 6)
{
cout << "\nYour new hunting tag amount cannot be 5 more or 5 less than the amount you\ndid last year.\nLast year you had: " << fdht << " fawn doe hunting tags.\n\n";
}
if((nabht-abht <= 5 && nadht-adht <= 5 && nfbht-fbht <= 5 && nfdht-fdht <= 5) && (nabht-abht >= -5 && nadht-adht >= -5 && nfbht-fbht >= -5 && nfdht-fdht >= -5))
{
nadht = adht;
nabht = abht;
nfbht = fbht;
nfdht = fdht;
check = 2;
check3 = 1;
}
if(!(nabht-abht <= 5 && nadht-adht <= 5 && nfbht-fbht <= 5 && nfdht-fdht <= 5) && !(nabht-abht >= -5 && nadht-adht >= -5 && nfbht-fbht >= -5 && nfdht-fdht >= -5))
{
cout << '\n';
}
}
}
if(check1 == 0)
{
ab = ab - abht;
ad = ad - adht;
fb = fb - fbht;
fd = fd - fdht;
}
if(check1 == 1)
{
ab = ab - nabht;
ad = ad - nadht;
fb = fb - nfbht;
fd = fd - nfdht;
}
if(check == 2)
{
check = 1;
}
check3 = 0;
check2 = 1;
}
void round()
{
f = (ceil(x))-x;
if(f >= 0.5)
{
x = floor(x);
}
if(f < 0.5)
{
x = ceil(x);
}
}
|