program runs but it outputs all the data

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
= is not the same as ==

weight >= 1500 <= 2200 is simply meaningless.

You were told this already.
Last edited on
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);
}
Topic archived. No new replies allowed.