123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
-
- public class MainApplication {
-
- public static void main(String[] args) {
- Console.println("Welcome to Vince and Ray's Calculator!");
- Double display = Console.getDoubleInput("Enter your first number: ");
- while(true){
- try{
-
- String operator = Console.getStringInput("Enter the operation you'd like to perform or type\n'help' to see a list of commands.");
- if(operator.equalsIgnoreCase("Add")){
- Integer entered = Console.getIntegerInput("Enter your second integer: ");
- CoreFunctions.add(display, entered);
- display = display + entered;
-
- }
- if(operator.equalsIgnoreCase("Subtract")){
-
- Integer entered = Console.getIntegerInput("Enter your second integer: ");
- CoreFunctions.subtract(display, entered);
- display = display - entered;
- }
- if(operator.equalsIgnoreCase("Multiply")){
- Integer entered = Console.getIntegerInput("Enter your second integer: ");
- CoreFunctions.multiply(display, entered);
- display = display * entered;
- }
- if(operator.equalsIgnoreCase("Divide")){
- Double entered = Console.getDoubleInput("Enter your second integer: ");
- if(entered != 0){
- CoreFunctions.divide(display, entered);
- display = display / entered;
- }else {
- System.out.println("Err");
- }
- }
- if(operator.equalsIgnoreCase("Exponent")){
- Double entered = Console.getDoubleInput("Enter your second integer: ");
- CoreFunctions.exp(display, entered);
- display = (double) Math.pow(display,entered);
- }
- if(operator.equalsIgnoreCase("squared")){
- ScientificFunctions.sqr(display);
- display = display*display;
- }
- if(operator.equalsIgnoreCase("square root")){
- ScientificFunctions.sqRoot(display);
- display = ((double)Math.sqrt(display));
- }
- if(operator.equalsIgnoreCase("Inverse Fraction")){
- ScientificFunctions.invFraction(display);
- display = 1/display;
- }
- if(operator.equalsIgnoreCase("Inverse Sign")){
- ScientificFunctions.invSign(display);
- display = -1/display;
- }
- if(operator.equalsIgnoreCase("sine")){
- ScientificFunctions.sin(display);
- display = (double)Math.sin(display);
- }
- if(operator.equalsIgnoreCase("cosine")){
- ScientificFunctions.cosine(display);
- display = (double)Math.cos(display);
- }
- if(operator.equalsIgnoreCase("tangent")){
- ScientificFunctions.tan(display);
- display = (double)Math.tan(display);
- }
- if(operator.equalsIgnoreCase("inverse tangent")){
- ScientificFunctions.atan(display);
- display = (double)Math.atan(display);
- }
- if(operator.equalsIgnoreCase("inverse sin")){
- ScientificFunctions.asin(display);
- display = (double)Math.asin(display);
- }
- if(operator.equalsIgnoreCase("inverse cosine")){
- ScientificFunctions.acosin(display);
- display = (double)Math.acos(display);
- }
- if(operator.equalsIgnoreCase("M+")){
- System.out.println("Memory Added");
- ScientificFunctions.memory=display;
- }
- if(operator.equalsIgnoreCase("MC")){
- System.out.println("Memory Cleared");
- ScientificFunctions.memory=0;
- }
- if(operator.equalsIgnoreCase("MRC")){
- System.out.println("Memory Recalled!");
- display = ScientificFunctions.memory;
- }
- if(operator.equalsIgnoreCase("clear")){
- System.out.print('\u000C');
- }
- if(operator.equalsIgnoreCase("clear dis")){
- System.out.print("Display Cleared!\n");
- display = (double) 0;
-
- }
- if(operator.equalsIgnoreCase("exit")){
- System.out.println("Thanks for using our Calculator!");
- break;
- }
- if(operator.equalsIgnoreCase("help")){
- System.out.println("You may Enter: \nOPERATORS\nAdd\nSubtract\nMultiply\nDivide\nExponent\nSquared\nSquare Root\nInverse Fraction\nInverse Sign\nSine\nCosine\nTangent\nInverse Tangent\nInverse Sine\nInverse Cosine\nInverse Tangent\n\nMEMORY FUNCTIONS\nM+ - Add to Memory\nMRC - Recall from Memory\nMC - Clear Memory\n\nDISPLAY MODE FUNCTIONS\nDec Mode - Display in Decimal Format\nHex Mode - Display in Hexadecimal Format\nBin Mode - Display in Binary Format\nOct Mode - Display in Octal Format\nToggle Display Mode - Chooses next display mode\nDeg Mode - Display Trig Functions in Degrees\nRad Mode - Display Trig Functions in Radians\nToggle Trig Mode - Chooses next trig display mode\n\nOTHER FUNCTIONS\nClear Display\nExit\nTemp Conversion - Convert Farenheit to Celcius, and vice versa.");
-
- }
- if(operator.equalsIgnoreCase("hex mode")){
- System.out.println("Hex Mode Activated");
- CoreFunctions.binMode = false;
- CoreFunctions.octMode = false;
- CoreFunctions.decMode = false;
- CoreFunctions.hexMode = true;
- }
- if(operator.equalsIgnoreCase("bin mode")){
- System.out.println("Binary Mode Activated");
- CoreFunctions.binMode = true;
- CoreFunctions.octMode = false;
- CoreFunctions.decMode = false;
- CoreFunctions.hexMode = false;
- }
- if(operator.equalsIgnoreCase("oct mode")){
- System.out.println("Octal Mode Activated");
- CoreFunctions.binMode = false;
- CoreFunctions.octMode = true;
- CoreFunctions.decMode = false;
- CoreFunctions.hexMode = false;
- }
- if(operator.equalsIgnoreCase("dec mode")){
- System.out.println("Decimal Mode Activated");
- CoreFunctions.binMode = false;
- CoreFunctions.octMode = false;
- CoreFunctions.decMode = true;
- CoreFunctions.hexMode = false;
- }
- if(operator.equalsIgnoreCase("Toggle Display Mode")){
- if(CoreFunctions.binMode == true){
- System.out.println("Octal Mode Activated!");
- CoreFunctions.binMode = false;
- CoreFunctions.octMode = true;
- CoreFunctions.decMode = false;
- CoreFunctions.hexMode = false;
-
- } else if(CoreFunctions.octMode == true){
- System.out.println("Decimal Mode Activated!");
- CoreFunctions.binMode = false;
- CoreFunctions.octMode = false;
- CoreFunctions.decMode = true;
- CoreFunctions.hexMode = false;
-
- }else if(CoreFunctions.decMode == true){
- System.out.println("Hexadecimal Mode Activated!");
- CoreFunctions.binMode = false;
- CoreFunctions.octMode = false;
- CoreFunctions.decMode = false;
- CoreFunctions.hexMode = true;
-
- }else if(CoreFunctions.hexMode == true) {
- System.out.println("Binary Mode Activated!");
- CoreFunctions.binMode = true;
- CoreFunctions.octMode = false;
- CoreFunctions.decMode = false;
- CoreFunctions.hexMode = false;
-
- }
- else {
- System.out.println("Err");
- }
-
- }
- if(operator.equalsIgnoreCase("deg mode")){
- System.out.println("Degree Mode Activated");
- ScientificFunctions.degMode = true;
- ScientificFunctions.radMode = false;
- }
- if(operator.equalsIgnoreCase("rad mode")){
- System.out.println("Radian Mode Activated");
- ScientificFunctions.degMode = false;
- ScientificFunctions.radMode = true;
- }
- if(operator.equalsIgnoreCase("Toggle Trig Mode")){
- if(ScientificFunctions.degMode == true){
- System.out.println("Radian Mode Activated!");
- ScientificFunctions.degMode = false;
- ScientificFunctions.radMode = true;
-
- } else if(ScientificFunctions.radMode == true){
- System.out.println("Degree Mode Activated!");
- ScientificFunctions.degMode = true;
- ScientificFunctions.radMode = false;
-
- }
- }
- if(operator.equalsIgnoreCase("Temp Conversion")){
- String conversion = Console.getStringInput("Enter 'F' to convert Farenheit to Celsius, Enter 'C' to convert Celcius to Farenheit");
- if(conversion.equalsIgnoreCase("f")){
- ScientificFunctions.fToC(display);
-
- } else if (conversion.equalsIgnoreCase("c")){
- ScientificFunctions.cToF(display);
- }
-
-
- }
- }catch(Exception e){
- System.err.println(e);
- System.err.println("System Error: Try again");
- continue;
-
- }
-
- }
- }
-
- }
- //Integer i = Console.getIntegerInput("Enter an integer");
- //Double d = Console.getDoubleInput("Enter a double.");
-
|