Find Perimeter Of Rectangle | Java Programs

Perimeter of Rectangle
Perimeter of Rectangle

Output:


*** Perimeter Of Rectangle ***

Enter the width of rectangle: 3
Enter the height of rectangle: 4

Perimeter is: 14.0

Try this compiler and compile Java code online!

Click Here For Java Online Compiler


Solution:


import java.util.Scanner;

public class PerimeterOfRectangle {

    public static void main(String[] strings) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("*** Perimeter Of Rectangle ***" + "\n");

        System.out.print("Enter the width of rectangle: ");
        double width = scanner.nextDouble();
        System.out.print("Enter the height of rectangle: ");
        double height = scanner.nextDouble();
        double perimeter = 2 * (height + width);
        System.out.println();
        System.out.println("Perimeter is: " + perimeter);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon