Editorial Staff - - Java Programming
In this program, we are going to share a Java program to calculate the perimeter of a square. If you are a Java beginner and want to start learning the Java programming, then keep your close attention in this tutorial as I am going to share how to write a Java program to calculate the perimeter of a square with the output.
Copy the below Java program and execute it with the help of Javac compiler. At the end of this program, We have shared the output of this program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import java.util.Scanner; public class JavaProgram { public static void main(String args[]) { int side, peri, area; Scanner scan = new Scanner(System.in); System.out.print("Enter Side Length of Square : "); side = scan.nextInt(); area = side*side; peri = 4*side; System.out.print("Area: " +area); System.out.print("\nPerimeter: " +peri); } } |
Enter side length of square: 5
Area:5
Perimeter: 25
Editorial Staff at FreeWebMentor is a team of professional developers leads by Prem Tiwari View all posts by Editorial Staff