Implement a function with the following signature:
int tryThis(int);
The function must do this in this order:
if the parameter is less than zero, throw any negative int. if p is less than 10, throw the string expression: "Bad value 1" if p more than 100, throw the string expression: "Bad value 2" if all the above tests are not true, check to see if the parameter is divisible by 10, throw 100. If no expression needs to be thrown, return the parameter cubed.
The tests will verify these conditions. There's no need to add any code in main unless you wish to test.
Assuming the language is C++, Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
//required method
int tryThis(int value){
//if value is negative, throwing a negative value
if(value<0){
throw value;
}
//if value is less than 10, throwing "Bad value 1"
if(value<10){
throw "Bad value 1";
}
//if value is greater than 100, throwing "Bad value 2"
if(value>100){
throw "Bad value 2";
}
//if value is divisible by 10, throwing 100
if(value%10==0){
throw 100;
}
//otherwise returning cube of value
return value*value*value;
}
Implement a function with the following signature: int tryThis(int); The function must do this in this...