How to know how many times double a is equal to 2 times double b
So i want to calculate the amount of times the rainfall of a particular month is
more than 2 times the temperature of that same month. i've tried some idea's like the one below, with the amount of times that the rainfall is more than 2 times the temperature presented by 'x'. but that doesn't seems to work. Could someone help me?
double T1, T2, T3, T4, T5;
double N1, N2, N3, N4, N5;
cout<<"Give the average temperature of january.\n";
cin>>T1;
cout<<"Give the average temperature of february.\n";
cin>>T2;
cout<<"Give the average temperature of march.\n";
cin>>T3;
cout<<"Give the average temperature of april.\n";
cin>>T4;
cout<<"Give the average temperature of may.\n";
cin>>T5;
cout<<"Give the average rainfall of january.\n";
cin>>N1;
cout<<"Give the average rainfall of fabruary.\n";
cin>>N2;
cout<<"Give the average rainfall of march.\n";
cin>>N3;
cout<<"Give the average rainfall of april.\n";
cin>>N4;
cout<<"Give the average rainfall of may.\n";
cin>>N5;
while(x > 0)
{
if(N1 >= 2*(T1) ) x + 1;
if(N2 >= 2*(T2) ) x + 1;
if(N3 >= 2*(T3) ) x + 1;
if(N4 >= 2*(T4) ) x + 1;
if(N5 >= 2*(T5) ) x + 1;
}
cout<<"The amount of wet months is now" << x <<" times.";
Ty, but i want to know how many times the rainfall greater is than twice the temperature. so i added an int which presents the amounts of time the rainfall is greater than twice the temperature.
When i enter the rainfall and the temperature, my "wetMonths" stays on 0, but i am entering numbers so N >= 2T.
cout<<"Give the average temperature of january.\n";
cin>>T1;
cout<<"Give the average temperature of february.\n";
cin>>T2;
cout<<"Give the average temperature of march.\n";
cin>>T3;
cout<<"Give the average temperature of april.\n";
cin>>T4;
cout<<"Give the average temperature of may.\n";
cin>>T5;
cout<<"Give the average rainfall of january.\n";
cin>>N1;
cout<<"Give the average rainfall of fabruary.\n";
cin>>N2;
cout<<"Give the average rainfall of march.\n";
cin>>N3;
cout<<"Give the average rainfall of april.\n";
cin>>N4;
cout<<"Give the average rainfall of may.\n";
cin>>N5;
if(N1 >= (2*T1)) wetMonths + 1;
if(N2 >= (2*T2)) wetMonths + 1;
if(N3 >= (2*T3)) wetMonths + 1;
if(N4 >= (2*T4)) wetMonths + 1;
if(N5 >= (2*T5)) wetMonths + 1;
cout<<"The amount of wet months is now " << wetMonths <<" times.";
This statement wetMonths + 1; does not increment wetMonths. It makes a calculation and does nothing with the result. What you intend to say is either: wetMonths = wetMonths + 1; (which takes current value of wetMonths, adds one to it, and stores the new result back into wetMonths) or ++wetMonths; (which is an operator that does the same thing in more compact syntax.)