Write a Java program to print the area and perimeter of a rectangleTest Data:Width = 5.5 Height = 8.5
Expected OutputArea is 5.6 * 8.5 = 47.60Perimeter is 2 * (5.6 + 8.5) = 28.20
public class Exercise13 { public static void main(String[] strings) { final double width = 5.6; final double height = 8.5; double perimeter = 2*(height + width); double area = width * height; System.out.printf("Perimeter is 2*(%.1f + %.1f) = %.2f \n", height, width, perimeter); System.out.printf("Area is %.1f * %.1f = %.2f \n", width, height, area); } }
Sample Output:
Perimeter is 2*(8.5 + 5.6) = 28.20 Area is 5.6 * 8.5 = 47.60
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer