using System; class BinToDec { public static void Main(string[] args) { { Boolean validbinary;//creates object to validate binary number entered by user String bin_1;//creates object to store binary number String dec_1;//creates object to store decimal number Console.WriteLine("Welcome, to....."); Console.WriteLine("Binary to Decimal Conversion, Version 1.0");//Introduces program Console.WriteLine();//blank line Console.WriteLine("Please enter the positve binary number you wish to convert to decimal."); //requests input from user bin_1 = Console.ReadLine();//reads input and stores binary number try//will validate the number to verify its valid binary number (boolean) { dec_1 = Convert.ToInt64(bin_1, 2).ToString();//converts binary number to decimal validbinary = true;//if binary valid will go to "if" instructions below } catch//if binary not valid { dec_1 = "";//declares value of null to dec_1 validbinary = false;//if binary not valid, go to "else" below } Console.WriteLine();//blank line if (validbinary == true)//from above, if binary valid, goes to this { Console.WriteLine("Your Binary Number of {0}", bin_1);//repeats users binary number Console.WriteLine("is equal to the Decimal Number {0}.", dec_1);//displays solution to user Console.WriteLine();//blank line Console.WriteLine();//blank line Console.WriteLine();//blank line Console.WriteLine("Thank You For Using Binary to Decimal Conversion.");//thanks user Console.WriteLine("Hit the Enter Key to Exit.");//instructs user to hit enter to end Console.ReadLine();//waits for input to end program } else//if binary not valid from above, goes to this { Console.WriteLine("*********************ERROR********************");//error message Console.WriteLine("***YOUR ENTRY IS NOT A VALID BINARY NUMBER!***"); Console.WriteLine("****OR BINARY NUMBER ENTERED IS TOO LARGE!****"); Console.WriteLine("*********************ERROR********************"); Console.WriteLine();//blank line Console.WriteLine("Hit the Enter Key to Exit.");//instructs user to hit enter to end Console.ReadLine();//waits for input to end program } } } }