Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.11 KB

README.md

File metadata and controls

40 lines (31 loc) · 1.11 KB

Hypotenuse Calculator

Overview

This is a simple Java program that calculates the hypotenuse of a right-angled triangle using the Pythagorean theorem:
[ \text{hypotenuse} = \sqrt{\text{side1}^2 + \text{side2}^2} ]

How it works

  • The program prompts the user to enter two sides of a right-angled triangle.
  • It calculates the hypotenuse using the formula ( \text{hypotenuse} = \sqrt{x^2 + y^2} ).
  • Finally, it displays the result.

Requirements

  • Java Development Kit (JDK)
  • A command-line terminal or any Java IDE like IntelliJ IDEA, Eclipse, etc.

How to run the program

  1. Compile the Program
    Open the terminal or command prompt, navigate to the directory where your file is located, and run:

    javac Main.java
  2. Run the Program
    After compiling, run the program with:

    java Main
  3. Enter Inputs

    • You will be prompted to enter the values for two sides of a right-angled triangle.
    • The program will then display the calculated hypotenuse.

Example Input/Output

Enter side x: 3
Enter side y: 4
The hypotenuse is: 5.0