Area and perimeter of a rectangle

The problem

Write a program that displays the area (size of the surface) and perimeter (the distance around) of a rectangle with the width of 4.5 and height of 7.9 using the following formula:

area = width * height

Breaking it down

To make the program more reusable and modular we will define calculateAreaOfRectangle that accepts width and height of a triangle. Next from the main method we will call the method and set it to a local variable. Finally outputting and formatting the results.

public static void main(String[] strings) {

    final double width = 4.5;
    final double height = 7.9;

    double area = calculateAreaOfRectangle(width, height);

    System.out.printf("%.1f * %.1f = %.2f", width, height, area);
}

private static double calculateAreaOfRectangle(final double width,
        final double height) {
    double area = width * height;
    return area;
}

Output

4.5 * 7.9 = 35.55