Area solver for shapes is just one of the exercises given by most programming instructors. Some other exercises are the following:
1. Celsius to Fahrenheit Temperature Converter
2. Identify if odd or even number
3. Display numbers using a for loop
4. Solve for the area of a triangle
5. Fibonacci Series
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 Area of Square
a = the length of the side
Java Code Area of Square
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);
}
}
So very helpful..This is awesome..
ReplyDeleteKeep up the good work and more publish pls..