A weather station validates the rain into its critical level by its raindrops fell. Make program
that will input number of raindrops fell, Check if raindrops fell is equal to 10,000 then display
“CRITICAL RAIN”. Your program will be terminated if you input zero in the raindrops fell.
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
int terminate_condition = 1;
//define a while loop that will terminate when condition == 0 i.e rain drops number == 0
while(terminate_condition==1)
{
cout<<"\nEnter the number of raindrops fell: ";
int number_of_rain_drops;
cin>>number_of_rain_drops;
if(number_of_rain_drops==10000)
{
cout<<"\nCRITICAL RAIN"<<endl;
}
else if(number_of_rain_drops==0)
{
//set terminate condition to zero to exit the while loop
terminate_condition=0;
//print exit message
cout<<"Program successfully exited"<<endl;
}
else if(number_of_rain_drops>10000)
{
cout<<"\nMORE THAN CRITICAL RAIN"<<endl;
}
else if(number_of_rain_drops>0)
{
cout<<"\nAVERAGE RAIN"<<endl;
}
else
{
cout<<"\nNumber of rain drops can't be negative"<<endl;
}
}
return 0;
}
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment