Friday 1 April 2016

Chapter 1 Exercise 9, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.

(Area and perimeter of a rectangle) Write a program that displays the area and perimeter of a rectangle with the width of 4.5 and height of 7.9 using the following formula:
area = width * height


public class Exercise_09 {

    public static void main(String[] strings) {

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

        double area = width * height;

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

No comments :

Post a Comment