this is whay i have so far the key is to write a program that test both if then else statments and switch statements. the program i a weather program tha will help you decide if you need to bring an umbrella,a coat or both. also i have to put it in a loop so it can run whenever i need to make a decioin.
#include < iostream>
using namespace std;
int temperature;
int average wind speedy;
int clear;
int cloudy;
int main()
{
int (temperature);
cout << "\n temperatue above 70F" << endl;
cin >> "no coat";
if int (average wind speed);
cout << "\n wind above 10 miles per hour and cloudy" << endl;
cin >> "bring coat, bring umbrella";
if int (clear);
cout << "\n clear" <<endl;
cin >> "no umbrella" ;
if int ( cloudy);
cout << "\n cloudy" << endl;
cin >> "bring umbrella" ;
Because you have too many issues with your code for us to really help you, without simply doing all the work for you. For starters, you need to use bools for some of the variables and jugging from the code sample, you also need to learn about statements and loops.
for one, you have global variables, then you are re declaring them within your main. you should not have to do that once you declare them the first time unless you are giving them a value.
when using a variable, you dont need to state its type every time you use it in code.
Your if statements are off. If statements are structured like this
1 2 3 4
if(//condition)
{
//code to execute should the condition be true
}
you also need to have an expression in the if statement like
1 2 3 4 5
if( temperature =< 60)
cout << "You need a coat" << endl;
if(weather = 'rainy' //or could be 'clear' or 0 or 1 if you are using bool expressions)
cout << "You need an umbrella" << endl;
Just making a minor correction so people don't get confused.
Stimson wrote:
1 2 3 4 5
if( temperature =< 60)
cout << "You need a coat" << endl;
if(weather = 'rainy' //or could be 'clear' or 0 or 1 if you are using bool expressions)
cout << "You need an umbrella" << endl;
On the second if statement you have some errors.
When comparing to a string like "rainy" you need to enclose it in double quotes not single quotes. Also you are comparing weather to "rainy" not assigning it. So instead of = it should be ==. Probably just typos but just wanted to make sure everything was clear. The correct version would look like so.
1 2
if (weather == "rainy")
cout << "You need an umbrella" << endl;