Hypotenuse
unknown
java
4 days ago
718 B
16
Indexable
import java.util.Scanner; public class maths_hypotenuse { public static void main(String[] args){ // Hypotenuse program // declaring c double c; // asking user for two sides Scanner input = new Scanner(System.in); System.out.println("Enter side a of triangle: "); double a = input.nextDouble(); System.out.println("Enter side b of triangle: "); double b = input.nextDouble(); input.close(); // doing Hypotenuse formula c = Math.sqrt(Math.pow(a, 2) + (Math.pow(b, 2))); // rounding to nearest int System.out.println("Hypotenuse: " + Math.round(c) + "cm"); } }
Editor is loading...
Leave a Comment