Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bg.unwe;
- import java.util.Scanner;
- public class Hypotenuse3 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Enter a: ");
- int a = scanner.nextInt();
- if (a <= 0) {
- System.out.println("The side A cannot be less than or equal to zero");
- return;
- }
- System.out.print("Enter b: ");
- int b = scanner.nextInt();
- if (b <= 0) {
- System.out.println("The side B cannot be less than or equal to zero");
- return;
- }
- if (a == b) {
- System.out.println("This is an isosceles triangle");
- }
- double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
- System.out.printf("The length of the hypotenuse is %.2f\n", c);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement