/** * Write a description of class DiplayMode here. * * @author (your name) * @version (a version number or a date) */ import java.util.Scanner; public class DiplayMode { private String currentMode = "decimal"; private double userInput; public void setResult(double result){ userInput = result; } public String enterMode(){ Console.println("Enter mode: decimal, binary, octal, hexadecimal"); Scanner scanner = new Scanner(System.in); String modeInput = scanner.nextLine(); return modeInput; } public void switchDisplayMode(String mode){ this.currentMode = mode; String value = convertNumber(this.currentMode); System.out.println(value); } public void switchDisplayMode() { String[] modes = {"decimal", "binary", "octal", "hexadecimal"}; currentMode = modes[0]; String value = convertNumber(currentMode); System.out.println(value); } public String convertNumber(String command){ String value = ""; if (command.equalsIgnoreCase("decimal")){ value = Double.toString(userInput); } else if (command.equalsIgnoreCase("binary")){ value = Integer.toBinaryString((int)userInput); } else if (command.equalsIgnoreCase("octal")){ value = Integer.toOctalString((int)userInput); } else if (command.equalsIgnoreCase("hexadecimal")){ value = Double.toHexString(userInput); } return value; } }