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...
2. Write a java program to: Define 3 integer variables var4, var5, and var6. Initialize these...
2. Write a java program to: Define 3 integer variables var4, var5, and var6. Initialize these variables with numbers input from console Right shift values in var4, var5 and var6, so var6 will get var5’s value, var5 will get var4’s value and var4 will get var6’s value Calculate the average of these numbers and save it into variable avg Display the following message: “the average of numbers value4, value5 and value6 is average-value”. (value4, value5, value6 and average-value should be...
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...
JAVA 4.35 (Sides of a Triangle) Write an application that reads three nonzero values entered by...
JAVA 4.35 (Sides of a Triangle) Write an application that reads three nonzero values entered by the user and determines and prints whether they could represent the sides of a triangle. Here's the code: import java.util.Scanner; class TriangleYN {    public static void main(String[] args) {        Scanner input = new Scanner(System.in);               double a;        double b;        double c;               System.out.print("Enter three sizes, separated by spaces(decimals values are acceptable):");...
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...
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