Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FormattingNumbers
- {
- static void Main()
- {
- Console.Write("Enter an integer 'a' (0 <= а <= 500): ");
- int a = int.Parse(Console.ReadLine());
- Console.Write("Enter a floating-point 'b': ");
- double b = double.Parse(Console.ReadLine());
- Console.Write("Enter a floating-point 'c': ");
- double c = double.Parse(Console.ReadLine());
- string binaryNumber = Convert.ToString(a, 2).PadLeft(10, '0');
- Console.WriteLine();
- if (a < 0)
- {
- Console.WriteLine("'a' < 0! 'a' should be (0 <= а <= 500)");
- }
- else if (a > 500)
- {
- Console.WriteLine("'a' > 500! 'a' should be (0 <= а <= 500)");
- }
- else
- {
- Console.WriteLine("|{0,-10:X} |{1}| {2,10:0.##}|{3,-10:F3}|", a, binaryNumber, b, c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement