Advertisement
Gesh4o

FormattingNumbers

Sep 10th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2.  
  3. class FormattingNumbers
  4. {
  5. static void Main()
  6. {
  7. {
  8. System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
  9. int a;
  10. while (true)
  11. {
  12. Console.WriteLine("Please insert three numbers: ");
  13. string firstNumber = Console.ReadLine();
  14. a = int.Parse(firstNumber);
  15. if (a < 0 || a > 500)
  16. {
  17. Console.WriteLine("Invalid Input!");
  18. }
  19. else
  20. {
  21. a = int.Parse(firstNumber);
  22. break;
  23. }
  24. }
  25. float b = float.Parse(Console.ReadLine());
  26. float c = float.Parse(Console.ReadLine());
  27. string binaryB = Convert.ToString(a, 2);
  28. int binary = int.Parse(binaryB);
  29. Console.WriteLine("|{0,-10:X}|{1:0000000000}|{2,10:.##}|{3,-10:f3}|", a, binary, b, c);
  30.  
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement