123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
-
- /**
- * Write a description of class SwitchDisplay here.
- *
- * Scientific Calculator Lab
- *
- * Brings up the switch display menu
- * Binary
- * Octal
- * Decimal
- * Hexadecimal
- *
- * Changes the mode for EVERYTHING
- *
- * Find a way to store the input and the input as a diff base
- * then whenever the base is changed, display the base.
- * pass the input into the methods to return the string.
- * EVERY TIME AN INPUT IS PLACED, IT WILL BE DISPLAYED AS AN OCTAL
- * boolean baseChange == true;
- * display the changed display
- */
- public class SwitchDisplay
- {
- // instance variables - replace the example below with your own
-
- /**
- * Switch Display Mode method
- * -> binary, octal, decimal, hexadecimal
- * switchDisplayMode() rotates through the options
- * switchDisplayMode(String mode) sets the display to the mode given
- */
-
- public void switchDisplay()
- {
- Console.println("Display Options"
- + "\n1: Binary"
- + "\n2: Octal"
- + "\n3: Decimal"
- + "\n4: Hexadecimal"
- + "\n5: Cancel - returns to Main Menu");
-
- }
-
- /**
- * Converts the user input into corresponding base types
- */
-
- public String toBinary(double userInput) {
-
- return Integer.toBinaryString((int)userInput);
-
- }
-
- public String toOctal(double userInput) {
-
- return Integer.toOctalString((int)userInput);
-
- }
-
- public String toDecimal(int userInput) {
-
- return Integer.toString(userInput);
-
- }
-
- public String toHexa(int userInput) {
-
- return Integer.toHexString((int)userInput);
-
- }
- }
|