Advertisement
iliqnvidenov

formatting numbers

Nov 28th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2.  
  3. class FormattingNum
  4. {
  5.     static void Main()
  6.     {
  7.         Console.WriteLine("Enter number A: ");
  8.         int a = int.Parse(Console.ReadLine());
  9.         Console.WriteLine("Enter number B: ");
  10.         float b = float.Parse(Console.ReadLine());
  11.         Console.WriteLine("Enter number C: ");
  12.         float c = float.Parse(Console.ReadLine());
  13.         if (a < 0 || a > 500)
  14.         {
  15.             Console.WriteLine("Invalid number \"A\"!");
  16.         }
  17.         else
  18.         {
  19.             Console.WriteLine("|{0,-10:X}|{1}|{2,10:F2}|{3,-10:F3}|", a, Convert.ToString(a, 2).PadLeft(10, '0'), b, c);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement