- Home
- Course
- Data types
- Double value

Tuesday, October 31, 2023
⁃
Difficulty:
Easy

Write a Java program that requests the width (x) and height (y) of a rectangle and calculate the perimeter, area and diagonal.

- Perimeter= sum of the four sides.
- Area= base x height.
- Diagonal= Pythagorean theorem.

4 6

Perimeter: 20 Area: 24 Diagonal: 7.211102550927978

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

The code has been successfully copied to the clipboard.

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

Practice with easy and intermediate Java exercises on different types of text, numeric or boolean data.