Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace NameToDecimalToBinary
- {
- class NameToDecimalToBinary
- {
- static void Main()
- {
- Console.Title = "Name to decimal to binary system converter";
- Console.WriteLine("Enter your name:");
- string name = Console.ReadLine();
- foreach (char c in name)
- {
- Console.WriteLine("The number of the character {0} according to the ASCII table is: {1}", c, (int)c);
- }
- string allNameInBinary = "";
- for (int i = 0; i < name.Length; i++)
- {
- Console.WriteLine("Enter your number:");
- int number = int.Parse(Console.ReadLine());
- string binary = "";
- while (number >= 1)
- {
- binary = (number % 2) + binary;
- number = number / 2;
- }
- allNameInBinary = allNameInBinary + " " + binary;
- Console.WriteLine("The binary output of your number is: {0}", binary);
- }
- Console.WriteLine("Your whole name in binary system is:{0}", allNameInBinary);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement