/** * Write a description of class ScientificFeatures here. */ public class ScientificFeatures { Console console = new Console(); // instance variables - replace the example below with your own public int Mode = 10; public String trigOptions= "degrees"; public double M; public String displayMode = "Decimal"; /** * Constructor for objects of class ScientificFeatures */ public ScientificFeatures(Console c) { console = c; } /** * A method */ public int switchDisplayMode(String value){ int[] modeOptions= new int[]{2,8,10,16}; if(value.equals("")){ if(Mode == 2){ Mode = modeOptions[1]; displayMode = "Octal"; } else if(Mode == 8){ Mode = modeOptions[2]; displayMode = "Decimal"; } else if(Mode == 10){ Mode = modeOptions[3]; displayMode = "Hexadecimal"; } else if(Mode == 16){ Mode = modeOptions[0]; displayMode = "Binary"; } } else if(value.equals("decimal")){ Mode = modeOptions[2]; displayMode = "Decimal"; } else if(value.equals("binary")){ Mode = modeOptions[0]; displayMode = "Binary"; } else if(value.equals("octal")){ Mode = modeOptions[1]; displayMode = "Octal"; } else if(value.equals("hexadecimal")){ Mode = modeOptions[3]; displayMode = "Hexadecimal"; } else{ System.out.print("Invalid choice try again"); Mode = Mode; } return Mode; } public String switchUnitsMode(String value){ if(value.equals("")){ if(trigOptions.equals("degrees")){ trigOptions = "radians"; } else if(trigOptions.equals("radians")){ trigOptions = "degrees"; } } else if(value.equals("degrees")){ trigOptions = "degrees"; } else if(value.equals("radians")){ trigOptions = "radians"; } else{ System.out.print("Invalid choice try again"); trigOptions= trigOptions; } return trigOptions; } public double sine(double value){ if (trigOptions.equals("degrees")){ value = Math.toRadians(value); } return console.changeCurrentValue(Math.sin(value)); } public double cosine(double value){ if (trigOptions.equals("degrees")){ if (value == 90){ return console.changeCurrentValue(0); } value = Math.toRadians(value); } return console.changeCurrentValue(Math.cos(value)); } public double tangent(double value){ if (trigOptions.equals("degrees")){ value = Math.toRadians(value); } return console.changeCurrentValue(Math.tan(value)); } public double invSine(double value){ if (trigOptions.equals("degrees")){ value = Math.toRadians(value); } return console.changeCurrentValue(Math.asin(value)); } public double invCosine(double value){ value = Math.toRadians(value); if (trigOptions.equals("degrees")){ value = Math.toRadians(value); } return console.changeCurrentValue(Math.acos(value)); } public double invTangent(double value){ value = Math.toRadians(value); if (trigOptions.equals("degrees")){ value = Math.toRadians(value); } return console.changeCurrentValue(Math.atan(value)); } }