Skip to content

This is a simple Java program that calculates the hypotenuse of a right-angled triangle using the Pythagorean theorem

Notifications You must be signed in to change notification settings

chalana05/Hypotenuse-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

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

About

This is a simple Java program that calculates the hypotenuse of a right-angled triangle using the Pythagorean theorem

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages