Answer:
Following are the code to the given question:
#include<iostream>// header file
using namespace std;
int main()//main function
{
int squirrels, walnuts;//defining integer variable
bool result = false; //defining a bool variable that holds a false value
cout<<"Enter the number of squirrels"<<endl;//print message
cin>>squirrels; // input integer value
cout<<"Enter the number of walnuts"<<endl;//print message
cin>>walnuts; // input integer value
if(squirrels < 1)//use if variable that checks squirrels value less than 1
{
result = false;//use result variable that holds false value
}
else//defining else block
{
if(squirrels <= 10)//use if variable that checks squirrels value less than equal to 10
{
if(walnuts < 15) //use if variable that checks walnuts value less than 15
result = false;//use result variable that holds false value
else if(walnuts <= 30)//use elseif block that checks walnuts less than equal to 30
result = true; //use result variable that holds true value
else //defining else block
result = false;//use result variable that holds false value
}
else if(squirrels <= 30)//use elseif that checks squirrels value less than equal to 30
{
if(walnuts >= 2*squirrels) //use if block to check walnuts value greater than equal to 2 times of squirrels
result = true; //use result variable that holds true value
else//defining else block
result = false;//use result variable that holds false value
}
else if(walnuts == 60 + squirrels - 30)//using elseif that checks walnuts value equal to squirrels
result = true;//use result variable that holds true value
else //defining else block
result = false;//use result variable that holds false value
}
if(result)//use if to check result
cout<<"True";//print True as a message
else //defining else block
cout<<"False";//print False as a message
return 0;
}
Output:
Enter the number of squirrels
10
Enter the number of walnuts
30
True
Explanation:
In this code, two integer variable "squirrels and walnuts" and one bool variable "result" is declared, in which the integer variable use that input the value from the user-end, and inside this the multiple conditional statements is used that checks integer variable value and use the bool variable to assign value as per given condition and at the last, it uses if block to check the bool variable value and print its value.