Click here to Skip to main content
15,511,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i choice number less than 74 the program shows "Not qualifies as a HurricaneEnter the wind speed in miles per hour.." instead of "Not qualifies as a HurricaneEnter"
and when i choice a number above 95 it gives me the same statement of the first if condition. all of them are Hurrican number 1 the number don't change.

What I have tried:

C++
#include <iostream>
using namespace std;
int main()
{
	int Wind_Speed;
	char A;
	while(static_cast<char>(Wind_Speed) != 'N') 
	{
		cout << "Enter the wind speed in miles per hour.. " << endl;
		cin >> Wind_Speed;
		
		if( Wind_Speed < 74){
			cout  << " Not qualifies as a Hurricane ";
		}
		else if (74 < Wind_Speed < 95){
			cout << " It is Hurrican number 1, " << Wind_Speed<< " mile per hour" <
Posted
Updated 19-Apr-21 21:26pm
v2
Comments
CPallini 20-Apr-21 2:11am    
The posted code is incomplete.
Yasser mohammed 1011 20-Apr-21 2:20am    
idk why i can't paste the full code but you can find the code here https://prnt.sc/11qifgp
CPallini 20-Apr-21 2:19am    
That's not the full code. And, if it is, then it is an incomplete one. No compiler will accept that.
Yasser mohammed 1011 20-Apr-21 2:28am    
can you help me? how to complete it? I'm new to c++ and trying to learn idk what should i do next.
CPallini 20-Apr-21 2:36am    
Patrice fixed the issue for you.

Quote:
when i choice number less than 74 the program shows "Not qualifies as a HurricaneEnter the wind speed in miles per hour.." instead of "Not qualifies as a HurricaneEnter"

May be you want to add End of lines?
C++
cout  << " Not qualifies as a Hurricane " << endl;

This is not what you think:
C++
if (74 < Wind_Speed < 95){
// should try
if (74 < Wind_Speed && Wind_Speed < 95){
// or just
if (Wind_Speed < 95){ // because you already know that Wind_Speed is not < 74)
 
Share this answer
 
Comments
CPallini 20-Apr-21 2:25am    
5.Good catch.
I need more caffeine, this morning.
Note: the OP may (and indeep should) drop the first comparison, but you should keep the else if.
Patrice T 20-Apr-21 2:33am    
Thank you.
"Note: the OP may (and indeep should) drop the first comparison, but you should keep the else if."
This is the meaning of last line of codde.
We don't have the complete code, so we can't even begin to help you fix this.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your compiler system, but a quick Google for the name of your IDE and "debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900