Advertisement
heysoul_sisypus

Pythagorean/SOHCAHTOA menu

Dec 8th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.93 KB | None | 0 0
  1. package javaapplication356;
  2. import java.util.*;
  3. import java.lang.Math;
  4. /**
  5.  *
  6.  * @author Student
  7.  */
  8. public class JavaApplication356 {
  9.  
  10.     /**
  11.      * @param args the command line arguments
  12.      */
  13.     public static void main(String[] args) {
  14.        Scanner scan= new Scanner (System.in);
  15.        System.out.println(" ");
  16.        System.out.println("Menu");
  17.        System.out.println("[1] C^2=a^2 + b^2");
  18.        System.out.println("[2] SOH");
  19.        System.out.println("[3] CAH");
  20.        System.out.println("[4] TOA");
  21.        System.out.print("Enter choice: ");
  22.        int a=scan.nextInt();
  23.        System.out.println("     ");
  24.        if (a==1){
  25.            System.out.println("[1] C^2= a^2 + b^2");
  26.            System.out.print("Enter a: ");
  27.            double b = scan.nextDouble();
  28.            System.out.print("Enter b: ");
  29.            double c = scan.nextDouble();
  30.            double d = (Math.pow(b,2)+ Math.pow(c, 2));
  31.            System.out.println(Math.sqrt(d));
  32.            }
  33.        else if (a==2){
  34.            System.out.println("SOH");
  35.            System.out.print("Enter Opposite: ");
  36.            double e=scan.nextDouble();
  37.            System.out.print("Enter Hypotenuse: ");
  38.            double f=scan.nextDouble();
  39.            System.out.println(e/f);
  40.            }
  41.        else if (a==3){
  42.            System.out.println("CAH");
  43.            System.out.print("Enter Adjacent: ");
  44.            double g=scan.nextDouble();
  45.            System.out.print("Enter Hypotenuse: ");
  46.            double h=scan.nextDouble();
  47.            System.out.println(g/h);
  48.            }
  49.        else if (a==4){
  50.            System.out.println("TOA");
  51.            System.out.print("Enter Opposite: ");
  52.            double i=scan.nextDouble();
  53.            System.out.print("Enter Adjacent: ");
  54.            double j=scan.nextDouble();
  55.            System.out.println(i/j);
  56.            }
  57.        else {
  58.            System.out.println("Try again");}
  59.        }
  60.    
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement