Write a program that calculates the area of the following figures:
· A square of side 0.666666667
· A rectangle of sides 1/9 and 4
Test the two calculated areas for equality. If the areas are equal output “The area of the two figures are equal” else output “The area of the two figures are not equal”
public class CalculationArea {
public static double squareAreaCalcSquare(double Side){
return Side*Side;
}
public static double rectangleAreaCalcSquare(double firstSide,double secondSide){
return firstSide*secondSide;
}
public static void main(String args[]){
double squareSide = 0.666666667;
double rectangleFirstSide = 1/9;
double rectangleSecondSide = 4;
if(squareAreaCalcSquare(squareSide)==rectangleAreaCalcSquare(rectangleFirstSide,rectangleSecondSide)){
System.out.println("The area of the two figures are equal.");
}
else{
System.out.println("The area of the two figures are not equals.");
}
}
}
Comments
Leave a comment