using System; using System.Collections; namespace csstack { class Class1 { static void Main(string[] args) { int num, baseNum; string again = "y"; //do it again Console.WriteLine(); while ((again == "y") || (again == "Y")) { Console.Write("Enter a decimal ynumber: "); num = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter a base: "); baseNum = Convert.ToInt32(Console.ReadLine()); Console.Write(num + " converts to "); MulBase(num, baseNum); Console.WriteLine(" in Base-" + baseNum); Console.Write("\nDo it again? Anwer 'y' or 'N':\t"); again = Console.ReadLine(); } Console.WriteLine(); } static void MulBase(int n, int b) { Stack digits = new Stack(); do { digits.Push(n % b); n /= b; } while (n != 0); while (digits.Count > 0) Console.Write(digits.Pop()); } } }
String.Format()
int.ToString()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)