#include <iostream>
#include <string>
using namespace std;
int main()
{
int actualage = 0, dogweight = 0;
cout << "Welcome to Sari's dog age calculator!" << endl;
cout << endl;
cout << "Please enter the actual age of your dog (1-16): " << endl;
cin >> actualage;
if (actualage<1) {
cout << "Invalid age. Please enter a number between 1 and 16. " << endl;
cin >> actualage;
}
else if (actualage>16){
cout << "Invalid age. Please enter a number between 1 and 16. " << endl;
cin >> actualage;
}
if ((actualage >= 1) && (actualage <= 16)) {
cout << "Please enter your dog's weight in pounds: " << endl;
cin >> dogweight;
}
if ((dogweight >= 20) && (dogweight <= 50) && (dogweight < 20) && (dogweight > 50)
&& (actualage >= 2) && (actualage <= 16)) {
cout << "Your dogs age is in human years is: " << 4 * actualage + 16 << endl;
}
else if (actualage == 1) {
cout << "Your dog's age in human years is: " << actualage + 14 << endl;
}
else if ((dogweight >= 20) && (dogweight <= 50) && (actualage >= 6) && (actualage <= 16)) {
cout << "Your dog's age in human years is: " << 4.5 * actualage + 16 << endl;
}
else if ((dogweight >= 50) && (actualage >= 6) && (actualage <= 16)) {
cout << "Your dog's age in human years is: " << 7.5 * actualage << endl;
}
system("PAUSE");
return 0;
}
I seem to have quite a few things right but there is one thing that happens that confuses me and that's that whenever I type in a dog's weight that is between 20 and 50 it doesn't calculate to get the age in human years.
Works fine for below 20 and over 50 but not in between.