Question

Meant to be written in Java JDK 14.0 Three double variables a, b, and c represent...

Meant to be written in Java JDK 14.0

Three double variables a, b, and c represent the length of 3 sides of a triangle. Write a program to determine if the triangle is right triangle. Find the hypotenuse side first.

Homework Answers

Answer #1
import java.util.Scanner;

public class CheckRightTriangle {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter lengths of three sides of a triangle: ");
        double a = in.nextDouble();
        double b = in.nextDouble();
        double c = in.nextDouble();
        if (a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b) {
            System.out.println("This triangle is a right triangle");
        } else {
            System.out.println("This triangle is not a right triangle");
        }
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Meant to be written in Java JDK 14.0 Generate four (4) integer numbers in range [0,...
Meant to be written in Java JDK 14.0 Generate four (4) integer numbers in range [0, 100]. Use Math methods to: (a) find the maximum and minimum numbers and display (b) calculate the absolute difference between the maximum number and minimum numbers, display
Create a class named MyTriangle that contains the following three methods: public static boolean isValid(double sidea,...
Create a class named MyTriangle that contains the following three methods: public static boolean isValid(double sidea, double sideb, double sidec) public static double area(double sidea, double sideb, double sidec) public static String triangletType(double a, double b, double c) The isValid method returns true if the sum of the two shorter sides is greater than the longest side. The lengths of the 3 sides of the triangle are sent to this method but you may NOT assume that they are sent...
Create a class named MyTriangle that contains the following three methods: public static boolean isValid(double sidea,...
Create a class named MyTriangle that contains the following three methods: public static boolean isValid(double sidea, double sideb, double sidec) public static double area(double sidea, double sideb, double sidec) public static String triangletType(double a, double b, double c) The isValid method returns true if the sum of the two shorter sides is greater than the longest side. The lengths of the 3 sides of the triangle are sent to this method but you may NOT assume that they are sent...
​​​​​​WRITE FLOWCHART AND PSEUDOCODE ONLY (C++) Write the flowchart and pseudocode for the following program (but...
​​​​​​WRITE FLOWCHART AND PSEUDOCODE ONLY (C++) Write the flowchart and pseudocode for the following program (but not the program itself.) In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. ( sidea2 = sideb2 + sidec2 / sideb2 = sidea2 + sidec2 / …..) The program will read three side lengths from a text file, and then print the lengths along with...
Write a basic c++ program to check whether a triangle is valid or not if the...
Write a basic c++ program to check whether a triangle is valid or not if the three sides are given: A triangle is valid if the sum of its two sides is greater than the third side. Let’s say that a, b, c is the sides of the triangle. A valid triangle must satisfy all these conditions: a + b > c a + c > b b + c > a (2 points) Generate random numbers 1-15 inclusive for...
JAVA a. An integer is a "Lucky Number" if it is divisible by 7 or is...
JAVA a. An integer is a "Lucky Number" if it is divisible by 7 or is divisible by 11 and it is in the range 1000 through 4000. Write a Boolean expression that is true if and only if myNum (an int variable) contains a Lucky Number. b. Let a and b represent the length and the width of a rectangle. The length of the diagonal of the rectangle can be calculated by the following mathematical expression. diagonalLength = squareRoot(a...
Design a Java class named Polygon that contains:  A private int data field named numSides...
Design a Java class named Polygon that contains:  A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4.  A private double data field named sideLength that defines the length of each side. The default value should be 5.0.  A private double data field named xCoord that defines the x-coordinate of the center of the polygon. The default value should be 0.0.  A private double...
Three 6.8 micro coulomb charges are arranged at the corners of a an equilateral triangle with...
Three 6.8 micro coulomb charges are arranged at the corners of a an equilateral triangle with sides of length 0.3 meters. They are held in place initially. The charges have a mass of 10 grams. One side of the triangle is on the horizontal axis. Find : a) size of the force, in Newtons, acting on the charge at the top of the triangle due to the other two charges b) the direction of the force, in degrees, as measured...
Three 5.8 micro coulomb charges are arranged at the corners of a an equilateral triangle with...
Three 5.8 micro coulomb charges are arranged at the corners of a an equilateral triangle with sides of length 0.6 meters. They are held in place initially. The charges have a mass of 10 grams. One side of the triangle is on the horizontal axis. Find the: a) size of the force, in Newtons, acting on the charge at the top of the triangle due to the other two charges, b) the direction of the force, in degrees, as measured...
Introduce variables to represent items of interest in the problem. For example, (1) Let n be...
Introduce variables to represent items of interest in the problem. For example, (1) Let n be the number to be found, or (2) Let a be Alice’s current age, or (3) Let r be the rate of the first car. (2) Write down an equation using the information given in the problem. This is the really important part for this particular assignment! (3) Solve the equation and find the value requested in the problem. One angle in a triangle is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT