123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
-
- public class CoreFunctions
- {
-
- public static boolean decMode = true;
- public static boolean hexMode = false;
- public static boolean binMode = false;
- public static boolean octMode = false;
- public static String hexOut;
- public static String binOut;
- public static String octOut;
-
-
- public static double add(double display, double entered) {
- if(decMode == true){
- System.out.println(display + entered);
- return display = display + entered;
- }
- else if(hexMode == true) {
- hexOut = Double.toHexString(display + entered);
- System.out.println(hexOut);
- return display = display + entered;
- }
- else if(binMode == true) {
- binOut = Long.toBinaryString(Double.doubleToRawLongBits((display + entered)));
- System.out.println(binOut);
- return display = display + entered;
- }
- else {
- octOut = Long.toOctalString(Double.doubleToRawLongBits((display + entered)));
- System.out.println(octOut);
- return display = display + entered;
- }
- }
-
- public static double subtract(double display, double entered) {
- if(decMode == true){
- System.out.println(display - entered);
- return display = display - entered;
- }
- else if(hexMode == true) {
- hexOut = Double.toHexString(display - entered);
- System.out.println(hexOut);
- return display = display - entered;
- }
- else if(binMode == true) {
- binOut = Long.toBinaryString(Double.doubleToRawLongBits((display - entered)));
- System.out.println(binOut);
- return display = display - entered;
- }
- else {
- octOut = Long.toOctalString(Double.doubleToRawLongBits((display - entered)));
- System.out.println(octOut);
- return display = display - entered;
- }
- }
-
- public static double multiply(double display, double entered) {
- if(decMode == true){
- System.out.println(display * entered);
- return display = display * entered;
- }
- else if(hexMode == true) {
- hexOut = Double.toHexString(display * entered);
- System.out.println(hexOut);
- return display = display * entered;
- }
- else if(binMode == true) {
- binOut = Long.toBinaryString(Double.doubleToRawLongBits((display * entered)));
- System.out.println(binOut);
- return display = display * entered;
- }
- else {
- octOut = Long.toOctalString(Double.doubleToRawLongBits((display * entered)));
- System.out.println(octOut);
- return display = display * entered;
- }
- }
-
- public static double divide(double display, double entered) {
- if(entered != 0){
- if(decMode == true){
- System.out.println(display / entered);
- return display = display / entered;
- }
- else if(hexMode == true) {
- hexOut = Double.toHexString(display / entered);
- System.out.println(hexOut);
- return display = display / entered;
- }
- else if(binMode == true) {
- binOut = Long.toBinaryString(Double.doubleToRawLongBits((display / entered)));
- System.out.println(binOut);
- return display = display / entered;
- }
- else {
- octOut = Long.toOctalString(Double.doubleToRawLongBits((display / entered)));
- System.out.println(octOut);
- return display = display / entered;
- }
- }else {
- System.out.println("Err");
- return display = 0;
- }
- }
-
- public static double exp(double display, double entered) {
- if(decMode == true){
- System.out.println( Math.pow(display,entered));
- return display = Math.pow(display,entered);
- }
- else if(hexMode == true) {
- hexOut = Double.toHexString(Math.pow(display,entered));
- System.out.println(hexOut);
- return display = Math.pow(display,entered);
- }
- else if(binMode == true) {
- binOut = Long.toBinaryString(Double.doubleToRawLongBits(Math.pow(display,entered)));
- System.out.println(binOut);
- return display = Math.pow(display,entered);
- }
- else {
- octOut = Long.toOctalString(Double.doubleToRawLongBits(Math.pow(display,entered)));
- System.out.println(octOut);
- return display = Math.pow(display,entered);
- }
-
-
- }
- }
-
|