Advertisement
Guest User

Untitled

a guest
Jan 11th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2.  
  3. class FormattingNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Enter an integer 'a' (0 <= а <= 500): ");
  8.         int a = int.Parse(Console.ReadLine());
  9.         Console.Write("Enter a floating-point 'b': ");
  10.         double b = double.Parse(Console.ReadLine());
  11.         Console.Write("Enter a floating-point 'c': ");
  12.         double c = double.Parse(Console.ReadLine());
  13.  
  14.         string binaryNumber = Convert.ToString(a, 2).PadLeft(10, '0');
  15.  
  16.         Console.WriteLine();
  17.  
  18.         if (a < 0)
  19.         {
  20.             Console.WriteLine("'a' < 0! 'a' should be (0 <= а <= 500)");
  21.         }
  22.  
  23.         else if (a > 500)
  24.         {
  25.             Console.WriteLine("'a' > 500! 'a' should be (0 <= а <= 500)");
  26.         }
  27.  
  28.         else
  29.         {
  30.             Console.WriteLine("|{0,-10:X} |{1}| {2,10:0.##}|{3,-10:F3}|", a, binaryNumber, b, c);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement