Need some help with this home work assignment ( I am a noob)

SOLVED

Assignment - Exercise #1:

Write a program using IF, ELSE IF, and ELSE statements that will ask the user to input today’s temperature. If the temperature is above 80 degrees, display a message saying “It is very hot today!”. If the temperature is below 40 degrees, display a message saying “It is very cold today!”. If the temperature is between 40 and 80 degrees, display a message saying “It is a beautiful day outside!”.

Now I've been sitting here scratching my head trying to figure this out, but I don't know how to fix it from displaying 2 of my cout statements because of one of the rules I have set in the else if statement.


#include <iostream> #include <Windows.h>

using namespace std;
void main()
{

	float temp;

	{


		cout << "What is todays temperature?  ";
		cin >> temp;

		if (temp >= 80)
			cout << "\nIt is very hot today!" << endl;

		else if (temp >= 40 <= 79);


		cout << "\nIt is a beautiful day outside!" << endl;

	 if (temp < 40);

	cout << "It is very cold outside!" << endl;

	system("Pause");

}

}

Posted Feb 25, 2016, 12:27 AM UTC

24
Loading comments…