Advertisement
Guest User

saagsag

a guest
Feb 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class pythag {
  4.     public static void main(String args[]) throws InterruptedException{
  5.         @SuppressWarnings("resource")
  6.         Scanner pythag = new Scanner(System.in);
  7.         @SuppressWarnings("resource")
  8.         Scanner userin = new Scanner(System.in);
  9.         System.out.println("Before starting please remember this only works on right angle triangles");
  10.         System.out.println("Please select a mode.");
  11.         System.out.println("If you are looking for the Hypotonuse side press 1");
  12.         System.out.println("If you are looking for either the adjacent or opposite side press 2");
  13.         int userimput;
  14.         userimput = userin.nextInt();
  15.        
  16.         if (userimput == 1){
  17.             System.out.println("You have selected to find the Hypotonuse");
  18.             double opposite, adjacent, hypotonuse, as, bs, cs;
  19.             int countdown = 5;
  20.             System.out.println("Please enter the mesurement of the Opposite/Adjacent side:");
  21.             opposite = pythag.nextDouble();
  22.             System.out.println("Please enter the measurement of the Adjacent/Opposite side:");
  23.             adjacent = pythag.nextDouble();
  24.             System.out.println("Thank You.. Now calculating the largest side");
  25.             System.out.println(countdown--);
  26.             Thread.sleep(1000);
  27.             System.out.println(countdown--);
  28.             Thread.sleep(1000);
  29.             System.out.println(countdown--);
  30.             Thread.sleep(1000);
  31.             System.out.println(countdown--);
  32.             Thread.sleep(1000);
  33.             System.out.println(countdown--);
  34.             Thread.sleep(1000);
  35.             System.out.println("...");
  36.             as = opposite * opposite;
  37.             bs = adjacent * adjacent;
  38.             cs = as + bs;
  39.             hypotonuse = Math.sqrt(cs);
  40.             System.out.print("Your answer is: ");
  41.             System.out.println(hypotonuse);
  42.         }if (userimput == 2){
  43.             System.out.println("You have selected to find the Opposite/Adjacent side!");
  44.             double opposite2, adjacent2, hypotonuse2, as2, bs2, cs2;
  45.             int countdown = 5;
  46.             System.out.println("Please enter the mesurement of the Hypotonuse side:");
  47.             hypotonuse2 = pythag.nextDouble();
  48.             System.out.println("Please enter the measurement of the Adjacent/Opposite side:");
  49.             adjacent2 = pythag.nextDouble();
  50.             System.out.println("Thank You.. Now calculating the final side");
  51.             System.out.println(countdown--);
  52.             Thread.sleep(1000);
  53.             System.out.println(countdown--);
  54.             Thread.sleep(1000);
  55.             System.out.println(countdown--);
  56.             Thread.sleep(1000);
  57.             System.out.println(countdown--);
  58.             Thread.sleep(1000);
  59.             System.out.println(countdown--);
  60.             Thread.sleep(1000);
  61.             System.out.println("...");
  62.             as2 =  hypotonuse2 * hypotonuse2;
  63.             bs2 = adjacent2 * adjacent2;
  64.             cs2 = as2 - bs2;
  65.             opposite2 = Math.sqrt(cs2);
  66.             System.out.print("Your answer is: ");
  67.             System.out.println(opposite2);
  68.        }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement