Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class pythag {
- public static void main(String args[]) throws InterruptedException{
- @SuppressWarnings("resource")
- Scanner pythag = new Scanner(System.in);
- @SuppressWarnings("resource")
- Scanner userin = new Scanner(System.in);
- System.out.println("Before starting please remember this only works on right angle triangles");
- System.out.println("Please select a mode.");
- System.out.println("If you are looking for the Hypotonuse side press 1");
- System.out.println("If you are looking for either the adjacent or opposite side press 2");
- int userimput;
- userimput = userin.nextInt();
- if (userimput == 1){
- System.out.println("You have selected to find the Hypotonuse");
- double opposite, adjacent, hypotonuse, as, bs, cs;
- int countdown = 5;
- System.out.println("Please enter the mesurement of the Opposite/Adjacent side:");
- opposite = pythag.nextDouble();
- System.out.println("Please enter the measurement of the Adjacent/Opposite side:");
- adjacent = pythag.nextDouble();
- System.out.println("Thank You.. Now calculating the largest side");
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println("...");
- as = opposite * opposite;
- bs = adjacent * adjacent;
- cs = as + bs;
- hypotonuse = Math.sqrt(cs);
- System.out.print("Your answer is: ");
- System.out.println(hypotonuse);
- }if (userimput == 2){
- System.out.println("You have selected to find the Opposite/Adjacent side!");
- double opposite2, adjacent2, hypotonuse2, as2, bs2, cs2;
- int countdown = 5;
- System.out.println("Please enter the mesurement of the Hypotonuse side:");
- hypotonuse2 = pythag.nextDouble();
- System.out.println("Please enter the measurement of the Adjacent/Opposite side:");
- adjacent2 = pythag.nextDouble();
- System.out.println("Thank You.. Now calculating the final side");
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println(countdown--);
- Thread.sleep(1000);
- System.out.println("...");
- as2 = hypotonuse2 * hypotonuse2;
- bs2 = adjacent2 * adjacent2;
- cs2 = as2 - bs2;
- opposite2 = Math.sqrt(cs2);
- System.out.print("Your answer is: ");
- System.out.println(opposite2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement