Area is the size of the surface of an object. In this article, we will discuss about the formula and java code in solving for the area of a square.
Formula
a = the length of the side
Java Code
import java.util.Scanner;Output
public class Square {
public static void main(String[] args) {
// solve for the area of a square
Scanner console=new Scanner(System.in);
System.out.println("Enter the side of the square: ");
double side = console.nextDouble();
double area=Math.pow(side,2);
System.out.println("The area of the square is "+area);
}
}
0 comments:
Post a Comment