Wednesday, January 27, 2016

JAVA SQUARE AREA: Solve for the Area of a Square

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; 
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);
}
}
Output


JAVA SQUARE AREA: Solve for the Area of a Square

JAVA SQUARE AREA: Solve for the Area of a Square Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment