Java program that computes and displays the perimeter of a letter­size (8.5 × 11 inch) sheet of paper and the length of its diagonal
Posted by Samath
Last Updated: February 08, 2021

Write a Java program that computes and displays the perimeter of a letter­size (8.5 × 11 inch) sheet of paper and the length of its diagonal.

public class Main
{
	public static void main(String[] args) {
	    
		final double PAPER_WIDTH = 8.5;
		final double PAPER_LENGTH = 11.0;
		
		double perimeter;
		double diagonal;
		
		perimeter = 2 * PAPER_LENGTH + 2 * PAPER_WIDTH;
		diagonal = Math.sqrt(Math.pow(PAPER_WIDTH, 2) + Math.pow(PAPER_LENGTH, 2));
		
		System.out.printf("Perimeter: %.2f\n", perimeter);
		System.out.printf("Diagonal length: %.2f\n",diagonal);
	}
}