Assignment #75
Code
///jack newsom
///period 5
///program RightTriangle
///filename RightTriangle.java
///date completed 10/13/15
import java.util.Scanner;
public class RightTriangle
{
public static void main( String[] args )
{
Scanner bot = new Scanner(System.in);
System.out.println("This program will check the three sides of a triangle to see if it is a right triangle.");
System.out.println("Enter three integers: ");
System.out.println("Side 1:");
int a = bot.nextInt();
System.out.println("Side 2: ");
int b = bot.nextInt();
while ( a > b )
{
System.out.println(b + " is smaller than " + a + ". Try again.");
System.out.println("Side 2:");
b = bot.nextInt();
}
System.out.println("Side 3: ");
int c = bot.nextInt();
while ( b > c )
{
System.out.println(c + " is smaller than " + b + ". Try again.");
System.out.println("Side 3:");
c = bot.nextInt();
}
Math.sqrt(a*a + b*b);
String ans;
if (c == Math.sqrt(a*a + b*b))
ans = "do";
else
ans = "do not";
System.out.println("These three sides (" + a + " " + b + " " + c + ") " + ans + " make a right triangle.");
}
}
Picture of the output