Java Program to find area of Square

Description

Get side of square and find area of square
Input 1:
4
Output1:
16

Solution

import java.util.*;
class Rectangle
{
 
       public static void main(String args[])
       {
 
            int side,area;
            Scanner sc=new Scanner(System.in);
            System.out.println("Get side of square and find area of square");
            System.out.println("Enter The Input 1:");
            side=sc.nextInt();
            area=side*side;
            System.out.println("The Output 1 Is:\n"+area);

        }

}

Explanation

Get side of a square (using scanner class)

Calculate area by multiplying side and side(area = side * side)

print area(using System.out.println()) 
Ramesh P Natarajan

Author - Ramesh P Natarajan

Learner, Professor, Technology Trainer, Software Developer and Content Marketer, very much passionate in the field of Software Application Development, Machine Learning and Search Engine Optimization.

Write to: admin@decodeschool.com





Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution