Advertisement
remote87

NameToBinaryAll

Aug 12th, 2015
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace NameToDecimalToBinary
  8. {
  9.     class NameToDecimalToBinary
  10.     {
  11.         static void Main()
  12.         {
  13.         Console.Title = "Name to decimal to binary system converter";
  14.             Console.WriteLine("Enter your name:");
  15.             string name = Console.ReadLine();
  16.             foreach (char c in name)
  17.             {
  18.                 Console.WriteLine("The number of the character {0} according to the ASCII table is: {1}", c, (int)c);
  19.             }
  20.             string allNameInBinary = "";
  21.             for (int i = 0; i < name.Length; i++)
  22.             {              
  23.                 Console.WriteLine("Enter your number:");
  24.                 int number = int.Parse(Console.ReadLine());
  25.                 string binary = "";
  26.                 while (number >= 1)
  27.                 {
  28.                     binary = (number % 2) + binary;
  29.                     number = number / 2;                  
  30.                 }
  31.                 allNameInBinary = allNameInBinary + " " + binary;
  32.                 Console.WriteLine("The binary output of your number is: {0}", binary);              
  33.             }
  34.             Console.WriteLine("Your whole name in binary system is:{0}", allNameInBinary);          
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement