Feb 28, 2016 at 4:48pm UTC
hey i figured out my last problem now the problem is if i select a certain type of horse and enter the weight it outputs all the weight categories and all the amounts to feed certain weight categories can someone tell me why also some of you told me to use code tags i clicked the code button at the bottom and tried posting it but it gave me an error
#include <iostream>
using namespace std;
int main()
{
char HorseType;
int weight;
cout << "What type of horse do you have ?" << endl;
cout << "Enter 1 (Light Riding Horse), 2 (Large Riding Horse), 3 (Draft Horse)"
<< endl;
cin >> HorseType;
cout << "Now enter the horse's weight" << endl;
cin >> weight;
if (HorseType = 1 && weight >= 840 && weight <= 1200)
{
cout << "WeightCategory: Optium" << endl;
cout << "Feed 3.0 pounds" << endl;
}
else if (HorseType = 1 && weight > 1200)
{
cout << "Weight Category: Overweight" << endl;
cout << "Feed 2.5 pounds" << endl;
}
else if (HorseType = 1 && weight < 840)
{
cout << "Weight Category: Underweight" << endl;
cout << "Feed 3.3 pounds" << endl;
}
if (HorseType = 2 && weight >= 1100 && weight <= 1300)
{
cout << "Weight Category: Optium" << endl;
cout << "Feed 3.0 pounds" << endl;
}
else if (HorseType = 2 && weight < 1100)
{
cout << "Weight Category: Underweight" << endl;
cout << "Feed 3.3 pounds" << endl;
}
if (HorseType = 2 && weight > 1300)
{
cout << "Weight Category: Overweight" << endl;
cout << "Feed 2.5 pounds" << endl;
}
if (HorseType = 3 && weight >= 1500 <= 2200)
{
cout << "Weight Category: Optium" << endl;
cout << "Feed 3.0 pounds" << endl;
}
else if (HorseType = 3 && weight < 1500)
{
cout << "Weight Category: Underweight" << endl;
cout << "Feed 3.3 pounds" << endl;
}
else if (HorseType = 3 && weight > 2200)
{
cout << "Weight Category: Overweight" << endl;
cout << "Feed 2.5 pounds" << endl;
}
system("pause");
return (0);
}
Last edited on Feb 28, 2016 at 4:50pm UTC
Feb 28, 2016 at 5:07pm UTC
=
is not the same as ==
weight >= 1500 <= 2200
is simply meaningless.
You were told this already.
Last edited on Feb 28, 2016 at 5:11pm UTC
Feb 28, 2016 at 6:12pm UTC
so like this?
#include <iostream>
using namespace std;
int main()
{
char HorseType;
int weight;
cout << "What type of horse do you have ?" << endl;
cout << "Enter 1 (Light Riding Horse), 2 (Large Riding Horse), 3 (Draft Horse)"
<< endl;
cin >> HorseType;
cout << "Now enter the horse's weight" << endl;
cin >> weight;
if (HorseType == 1 && weight >= 840 && weight <= 1200)
{
cout << "WeightCategory: Optium" << endl;
cout << "Feed 3.0 pounds" << endl;
}
else if (HorseType == 1 && weight > 1200)
{
cout << "Weight Category: Overweight" << endl;
cout << "Feed 2.5 pounds" << endl;
}
else if (HorseType == 1 && weight < 840)
{
cout << "Weight Category: Underweight" << endl;
cout << "Feed 3.3 pounds" << endl;
}
if (HorseType == 2 && weight >= 1100 && weight <= 1300)
{
cout << "Weight Category: Optium" << endl;
cout << "Feed 3.0 pounds" << endl;
}
else if (HorseType == 2 && weight < 1100)
{
cout << "Weight Category: Underweight" << endl;
cout << "Feed 3.3 pounds" << endl;
}
if (HorseType == 2 && weight > 1300)
{
cout << "Weight Category: Overweight" << endl;
cout << "Feed 2.5 pounds" << endl;
}
if (HorseType == 3 && weight >= 1500 && weight <= 2200)
{
cout << "Weight Category: Optium" << endl;
cout << "Feed 3.0 pounds" << endl;
}
else if (HorseType == 3 && weight < 1500)
{
cout << "Weight Category: Underweight" << endl;
cout << "Feed 3.3 pounds" << endl;
}
else if (HorseType == 3 && weight > 2200)
{
cout << "Weight Category: Overweight" << endl;
cout << "Feed 2.5 pounds" << endl;
}
system("pause");
return (0);
}