Advertisement
SSkrev

Formatting Numbers

Mar 17th, 2014
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2.  
  3. class FormattingNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("a=");
  8.         int a = int.Parse(Console.ReadLine());
  9.         if (a >= 0 && a <= 500)
  10.         {
  11.             Console.Write("b=");
  12.             float b = float.Parse(Console.ReadLine());
  13.             Console.Write("c=");
  14.             float c = float.Parse(Console.ReadLine());
  15.             string inHex = a.ToString("x");
  16.             string inBin = Convert.ToString(a, 2);
  17.             Console.Write("|{0,-10}", inHex);
  18.             Console.Write("|{0,0}|", inBin);
  19.             Console.Write("{0,10}|", Math.Round(b, 2));
  20.             Console.WriteLine("{0,-10}|", Math.Round(c, 3));                    
  21.         }
  22.         else
  23.         {
  24.             Console.WriteLine("a need to be in interval 0-500");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement