Here is the signature of a method computeArea(float side). Thebody of this metho
ID: 3611214 • Letter: H
Question
Here is the signature of a method computeArea(float side). Thebody of this method ( the part within the curly braces) iscurrently empty. pubblic voidcomputeArea(float side) { } Complete the body of this method by writing inside the curlybraces the code corresponding to the following requirements: - Define a variable called area - Compute the area of the square on the basis of the providedside and assign this value to variable area. - Test if the area of the square is bigger than 100;print "This is a big square" if it is the case, and print "This isa small square" otherwise. - Rewrite the method so that it returns a Boolean value Trueif the area of the square is bigger than 100 and Falseotherwise. please give separatly the answer related to the requirements,so that i can see your steps. Thanks Here is the signature of a method computeArea(float side). Thebody of this method ( the part within the curly braces) iscurrently empty. pubblic voidcomputeArea(float side) { } Complete the body of this method by writing inside the curlybraces the code corresponding to the following requirements: - Define a variable called area - Compute the area of the square on the basis of the providedside and assign this value to variable area. - Test if the area of the square is bigger than 100;print "This is a big square" if it is the case, and print "This isa small square" otherwise. - Rewrite the method so that it returns a Boolean value Trueif the area of the square is bigger than 100 and Falseotherwise. please give separatly the answer related to the requirements,so that i can see your steps. ThanksExplanation / Answer
public void computeArea(float side){
float area; //declaration of variable area
area = (side * side); //calculationof the area of the square
if( area >100) ///compares whether area isbigger than 100
{
System.out.println("This is a bigsquare"); //prints This is a big square
}
else
{
System.out.println("This is asmall square"); //prints This is a small square
}
}//end of method
Method rewritten such that it returns true if area isbigger than 100 else it returns false ..(themodification from the previous method are highlighted):
public boolean computeArea(float side)
{
float area; //declaration of variable area
area = (side * side); //calculationof the area of the square
if( area >100) ///compares whether area isbigger than 100
{
return true;
}
else
{
returnfalse;
}
return false;
}//end of method
public boolean computeArea(float side)
{
float area; //declaration of variable area
area = (side * side); //calculationof the area of the square
if( area >100) ///compares whether area isbigger than 100
{
return true;
}
else
{
returnfalse;
}
return false;
}//end of method