1.

Write a program to accept the length of a side of a square and display its area and perimeter.related to java programings classX level question plz help urgent

Answer»

There is three method to take input in java
1.input STREAM reader
2.console
3.SCANNER(class)
so i am using THIRD Scanner first import them by
import java.util.Scanner; and so on...
check out this program
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int side=sc.nextInt();
int perimeter=(4*side);
System.out.println("the perimeter of square is: "+perimeter);
int area=(side*side);
System.out.println("the area of square is: "+area);
}
}



Discussion

No Comment Found