Do-While Loops part 2 #75 (Algebra)

Code

/// Name: Amir Salehi
/// Period: 7
/// Program Name:Right Triangle Checker
/// File Name:RightTriangleChecker.java
/// Date Finished: 1/6/2016

 
import java.util.Scanner;

public class RightTriangleChecker
{
	public static void main( String[] args )
	{
		Scanner input = new Scanner(System.in);

		
    
        System.out.println("Enter three integers : ");
        System.out.print("Side 1: ");
        int one = input.nextInt();
        System.out.println("");
        System.out.print("Side 2: ");
        int two = input.nextInt();
        System.out.println("");
        
        while (two < one) {
            System.out.println( two + " is smaller than " + one + " Try again.");
            System.out.print("Side 2: ");
            two = input.nextInt();
        }
            System.out.println("");
        System.out.print("Side 3: ");
        int three = input.nextInt();
        
                while (three < two) {
            System.out.println( three + " is smaller than " + two + " Try again.");
            System.out.print("Side 3: ");
            three = input.nextInt();
        }
        
        if (one * one + two * two == three * three) {
            System.out.println("");
            System.out.println("Your three sides are " + one + " " + two + " " + three);
            System.out.println("These sides *do* make a right triangle.  Yippy-skippy!");
        }else {
                System.out.println("");
            System.out.println("Your three sides are " + one + " " + two + " " + three);
                System.out.println("NO!  These sides do not make a right triangle!");

        
      
}
}
    }





    

Picture(s) of the output

Assignment 7 Assignment 7

Back to Homepage