if/else statement not producing the cout statement

First, thank you. I am a beginner and trying to learn C++. I appreciate your help.

My problem is with if/ else. When I run the "blue' color, I will get both cout statements, "a weed will grow", and 'a mushroom will grow." Also, when I put the incorrect temperature, it will not produce the else statement, "a mushroom will grow."

Again, thank you for your help.

[#include <iostream>
#include <string>
using namespace std;

int main()

{
// get seed color
string seedColor = "";
cout << "Enter the seed color (red or blue): \n";
cin >> seedColor;

// get temp

int temp = 0;
cout << "Enter the temperature (F): \n";
cin >> temp;


// get the soil moisture
string soilMoisture = "";
cout << "Enter the soil moisture (wet of dry): \n";
cin >> soilMoisture;


// If red seed
if (seedColor == "red")
{
// If temp >=75
if(temp >= 75)
{
//If soil is wet
if(soilMoisture == "wet")
{
cout << "A sunflower will grow. \n";
}
// Output sunflower
if(soilMoisture == "dry")
// If the soil is dry
{
cout << "A mushroom will grow. \n";
}

}

else
{
cout << " You will get a mushroom. \n";
}
}

if (seedColor == "blue")
{
if(temp >= 60 && temp <= 70)
{

if(soilMoisture == "wet")
{
cout << " A weed will grow. \n.";
}

if(soilMoisture == "dry")
{
cout << "A sunflower will grow. \n.";
}
// Otherwise
else
{
cout << "A mushroom will grow. \n";
}
}

}

}
Compare the locations of your two else statements.
This is one of those occasions where using code tags would make it so much easier for you and us to see the problem.

http://www.cplusplus.com/articles/z13hAqkS/
Thank you. I looked at the location and figured it out. Thank you, again. This board has been very helpful.
Topic archived. No new replies allowed.