Question

In a right triangle, the square of the length of one side is equal to the...

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.

Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle.

If the triangle is a right triangle, output It is a right-angled triangle

If the triangle is not a right triangle, output It is not a right-angled triangle

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class Triangle {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter 3 sides of triangle: ");
       double side1=sc.nextDouble();
       double side2=sc.nextDouble();
       double side3=sc.nextDouble();
       //checking if A^2+B^2=C^2
       if(side3*side3==(side1*side1)+(side2*side2)) {
           System.out.println("It is a right-angled triangle");
       }
       else {
           System.out.println("It is not a right-angled triangle\r\n");
       }
   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
In a right triangle, the square of the length of one side is equal to the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • //////// ONLY JAVA **** //////// ONLY JAVA **** 5. In a right triangle, the square of...

    //////// ONLY JAVA **** //////// ONLY JAVA **** 5. 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. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. (Have the user enter the lengths 3, 4, and 5).

  • c++ The length of the hypotenuse of a right-angled triangle is the square root of the...

    c++ The length of the hypotenuse of a right-angled triangle is the square root of the sum of the squares of the other two sides. Write a function calcH that accept two doubles as function arguments and returns a double. Prompt the user for the length of base and the perpendicular side of the triangle. Use the pow and sqrt functions from cmath to perform the calculations

  • The longest side of a right triangle is 25 m in length. One of the other...

    The longest side of a right triangle is 25 m in length. One of the other sides is 17 m longer than the shortest side. Find the lengths of the two shorter sides of the triangle. The lengths of the two shorter sides are m. (Type an integer or a decimal. Use a comma to separate answers as needed.)

  • PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP...

    PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT: #include <iostream> using namespace std; int main() { //variables here    do { // program here             }while (true);    } Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.program to have a user input the length of three sides of a triangle. Allow the user to enter the sides...

  • (JAVA) Implement a Triangle class. Any triangle can be represented by its THREE sides. Therefore,...

    (JAVA) Implement a Triangle class. Any triangle can be represented by its THREE sides. Therefore, your class will have THREE private member variables → side1, side2 and side3. Use the double data type to represent the triangle sides. In addition, please provide public methods that perform the following FIVE tasks: ▪ An input method that obtains the appropriate values for the three sides from the user. While entering the values of the three sides, please remember the triangle property that...

  • Write a program which, given the length of three sides of a triangle, will determine whether...

    Write a program which, given the length of three sides of a triangle, will determine whether the triangle is right- angled. Assume that the third argument to the function is always the longest side. It will return True if the triangle is right-angled, or False otherwise. python

  • Theorems Regarding Right Angle Triangles

    Summarize Euclid's approach to proving proposition 1.47 and 1.48.1.47: In right-angled triangles, the square on the side subtending the right angle is equal to the squares on the sides containing the right angle.1.48: If In a triangle the square on one of the sides be equal to the squares on the remaining two sides of the triangle, the angle contained by the remaining two sides of the triangle is right.

  • help im alittle lost my teacher posted all this its suppose to be in C++ language....

    help im alittle lost my teacher posted all this its suppose to be in C++ language. can yoh leave comments ans type the code thank you Write a C++ program that accepts the lengths of three sides (a,b,c) of a triangle as input from the user Validate the user input, so that sides a, b, c can only be POSITIVE. The program output should indicate whether or not the triangle is an Equilateral Triangle, a Right Triangle, Isosceles which is...

  • Your math professor asked you to determine whether triangles are equilateral, isosceles, or scalene triangles. You...

    Your math professor asked you to determine whether triangles are equilateral, isosceles, or scalene triangles. You need to write a MATLAB program that accepts the side lengths for sides A, B, and C of a triangle and compares the side lengths in order to determine if the triangle is equilateral, isosceles, or scalene. Each triangle will only be classified as a single type based on the definitions below: 1. An equilateral triangle is a triangle in which all three sides...

  • Problem a (PA4a.java) Write a program to evaluate the area of a triangle given the lengths...

    Problem a (PA4a.java) Write a program to evaluate the area of a triangle given the lengths of its sides using Heron's Formula. Here is an outline: Get the three side lengths from the user (which might have decimal values): a, b, c. Check to ensure that the sides are valid for a triangle. Importantly, the sum of the lengths of any two sides must be larger than the length of the third side (you must check all three sides this...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT