Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- System.out.println("Input 3 integers: ");
- System.out.println("Side 1:");
- int s1 = keyboard.nextInt();
- System.out.println("Side 2: ");
- int s2 = keyboard.nextInt();
- while (s2 < s1){
- System.out.println(s2 + " is smaller than " +s1+ ". Try again.");
- System.out.println("Side 2: ");
- s2 = keyboard.nextInt();
- }
- System.out.println("Side 3: ");
- int s3 = keyboard.nextInt();
- while (s3 < s2){
- System.out.println(s3+ " is smaller than " +s2+ ". Try again.");
- System.out.println("Side 3: ");
- s3 = keyboard.nextInt();
- }
- System.out.println();
- System.out.println("The three sides are: " +s1+ ", " +s2+ ", " +s3+ "." );
- int p = s1*s2*s3;
- double sqrt3 = Math.sqrt(p);
- if (s3 == sqrt3){
- System.out.println("This is a right triangle.");
- } else {
- System.out.println("This is not a right triangle.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement