HELP ME PLEASE :(

please help me..


#include<iostream.h>
main()
{
double n;
cout<<"ENTER TEMPERATURE:";
cin>>n;
if
(WHAT SHOULD I PUT HERE?) //WHEN I INPUT 50 TO 100 IT WILL DISPLAY SUPER HOT, SAME AS THE OTHER
{
cout<<"SUPER HOT";
}
else if
(WHAT SHOULD I PUT HERE?)
{
cout<<"HOT";
}
else if
(WHAT SHOULD I PUT HERE?
{
cout<<"NORMAL";
}
else if
(WHAT SHOULD I PUT HERE?)
{
cout<<"COLD";
}
else if
(WHAT SHOULD I PUT HERE?)
{
cout<<"SUPER COLD";
}
else
{
cout<<"INVALID INPUT";
}
cout<<"\n\n";
system("pause");
return 0;
}
believeme wrote:
(WHAT SHOULD I PUT HERE?) //WHEN I INPUT 50 TO 100 IT WILL DISPLAY SUPER HOT, SAME AS THE OTHER


 
if (n > 50 && n < 100)
Last edited on
what if 38 to 49?
if (n > 50 && n < 100)
what are the condition for Hot , cold , super cold ?

and i think that 38 to 49 will go into invalid input ..
Last edited on
create a program that will display the temperature..

temperature description

100-50 super hot
49-38 hot
37-30 normal
29-16 cold
15-0 super cold
ok
1
2
3
4
5
6
7
8
9
10
if( n > 0 && n < 15 ) 
//super cold . 
if( n > 16 && n < 29 ) 
//cold
if( n > 30  && n < 37)
//normal 
if (  n > 38 && n < 49 ) 
// hot
if (n > 50 && n < 100)
// super hot .  
i put = to ( n >= 0 && n >= 15)

thanks :)
hello believeme. I have worked on your problem this morning. You need to have a clearer understanding of the logic within the if statement. I have cleared it up for you as an example. I hope it works and I hope you can learn from it and move on in your programming career. For scenarios like this I like to use a do while loop to loop through my logic without having to constantly execute it over and over to test. Good luck.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
using namespace std;

int main()
{
double n;
do {
cout << "ENTER TEMPERATURE: ";
cin>>n;
if (n <= 100 && n >= 50) //WHEN I INPUT 50 TO 100 IT WILL DISPLAY SUPER HOT, SAME AS THE OTHER
{
cout<<"SUPER HOT\n";
}
else if (n <= 49 && n >= 38)
{
cout<<"HOT\n";
}
else if (n <= 37 && n >= 30)
{
cout<<"NORMAL\n";
}
else if (n <= 29 && n >= 16)
{
cout<<"COLD\n";
}
else if (n <= 15 && n >= 0)
{
cout<<"SUPER COLD\n";
}
else if (n < 0)
{
cout<<"It must be FREEZING!\n";
}
else if (n > 100) {
	cout << "It must be too hot!\n";
}
else {
	cout << "Good bye!\n";
}
} while (n != -1);

system("pause");
return 0;
} 
were not in looping yet.. but thanks.. :) i need to take advance reading.. :)
You can restructure the set of if statements such that you don't miss anything. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
std::string GetTempDescription(double temp)
{
    std::string desc;

    if (temp >= 50.0)
        desc = "Super hot";
    else if (temp >= 38.0)
        desc = "Hot";
    else if (temp >= 30.0)
        desc = "Normal";
    // ... and so on.

    return desc;
}
Topic archived. No new replies allowed.