Question: The class with some potentially helpful methods. public class E2a extends Application { /** * Potentially useful map of trig function names * and their

 The class with some potentially helpful methods. public class E2a extends

The class with some potentially helpful methods. public class E2a extends Application { /**  * Potentially useful map of trig function names  * and their associated functions  */ public static final MapString, FunctionDouble, Double>> OPS = new LinkedHashMap(); static { OPS.put("sin", x -> Math.sin(x)); OPS.put("cos", x -> Math.cos(x)); OPS.put("tan", x -> Math.tan(x)); } /**  * Potentially useful list of pertinent angles  */ public static final int[] ANGLES = {0, 30, 45, 60, 90}; /**  * Output for tan(90 degrees)  */ public static final String UNDEFINED = "undefined"; /**  * Potentially useful map of the numerical  * result of trig operations and associated  * human-friendly text  */ public static final MapDouble, String> NUMERICAL_RESULTS = new HashMap(); static { NUMERICAL_RESULTS.put( 0., "0" ); NUMERICAL_RESULTS.put( 1., "1" ); NUMERICAL_RESULTS.put( 0.5, "1 / 2" ); NUMERICAL_RESULTS.put( ( Math.sqrt( 2. ) / 2 ), "sqrt(2) / 2" ); NUMERICAL_RESULTS.put( ( Math.sqrt( 3. ) / 2. ), "sqrt(3) / 2" ); NUMERICAL_RESULTS.put( ( Math.sqrt( 3. ) / 3. ), "sqrt(3) / 3" ); NUMERICAL_RESULTS.put( ( Math.sqrt( 3. ) ), "sqrt(3)" ); } The Method I need help :  /**  * Returns the result of performing  * a trig operation on a supplied  * angle (in degrees)  *   * @param op sin/cos/tan  * @param angle 0/30/45/60/90  * @return human-readable result  */ public static String trigResult(String op, int angle) { return ""; // replace with your code } Test cases to test trigResult :  
 public void testTrig() { _testTrigResult("sin", 0, "0"); _testTrigResult("sin", 30, "1 / 2"); _testTrigResult("sin", 45, "sqrt(2) / 2"); _testTrigResult("sin", 60, "sqrt(3) / 2"); _testTrigResult("sin", 90, "1"); _testTrigResult("cos", 0, "1"); _testTrigResult("cos", 30, "sqrt(3) / 2"); _testTrigResult("cos", 45, "sqrt(2) / 2"); _testTrigResult("cos", 60, "1 / 2"); _testTrigResult("cos", 90, "0"); _testTrigResult("tan", 0, "0"); _testTrigResult("tan", 30, "sqrt(3) / 3"); _testTrigResult("tan", 45, "1"); _testTrigResult("tan", 60, "sqrt(3)"); _testTrigResult("tan", 90, "undefined"); } - Thank you  

First, implement the trigResult method to return human-friendly text for all combinations of operations/angles (see the JavaDoc for details). You will earn 5 points for successfully implementing this method. (Note: there are much better ways to do this than a giant if-else statement)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!