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";
}
}