123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
-
- /**
- * 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));
- }
-
-
- }
-
|