public void ShowResult() { Console.WriteLine("In octal: " + octNumber); Console.WriteLine("In decimal: " + octalToDecimal()); string Result = octalToDecimal(); DecimalSystem dec = new DecimalSystem(Result); Console.WriteLine(dec.DecimalToBinary()); Console.WriteLine(dec.DecimalToHex()); }
public void ShowResult() { Console.WriteLine("In hexadecimal: " + hexNumber); Console.WriteLine("In decimal: " + HexToDec()); double result = HexToDec(); DecimalSystem decimalSystem = new DecimalSystem(result.ToString()); Console.WriteLine(decimalSystem.DecimalToBinary()); Console.WriteLine(decimalSystem.DecimalToOctal()); }
static public void CheckBase(string inputArray) { List <char> inputList = new List <char>(); // check if an input is fraction for (int i = 0; i < inputArray.Length; i++) { if (inputArray[i] == '.') { break; } else { inputList.Add(inputArray[i]); } } char[] inputArr = inputList.ToArray(); try { INumeralSystem numeralSystem; if (inputArray[1] == 'x' || inputArray[1] == 'X') // if an input is hexadecimal { numeralSystem = new HexSystem(inputArray); Console.WriteLine("Your number is in hexadecimal system! We converted it to every systems: \n"); } else { if (isOctal(inputArray.ToString()) && inputArr.Length != 1) // if an input is octal { numeralSystem = new OctalSystem(inputArray); Console.WriteLine("Your number is in octal system! We converted it to every systems: \n"); } else { numeralSystem = new DecimalSystem(inputArray); // if an input is decimal Console.WriteLine("Your number is in decimal system! We converted it to other systems: \n"); } } numeralSystem.ShowResult(); } catch (Exception e) { Console.WriteLine(e.Message + "\nWrong input, please try again"); } }