write a program to print the area of a square if its side 8m java program
Answers
Answered by
4
Solution.
The given problem is solved using language - Java.
public class SquareArea{
public static void main(String s[]){
double side,area;
side = 8.0;
area = side * side;
System.out.println("Side of the square is " + side + " metre.");
System.out.println("Therefore, area of the square is: " + area + " square metre.");
}
}
Explanation.
- Here, we have initialised side = 8 i.e., the side of the square is 8 m.
- Then, we have calculated area using formula area = side².
- Then, the area of the square is displayed on the screen.
See attachment for output.
Attachments:
Similar questions