Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FormattingNumbers
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Please enter an integer number N satisfying the condition 0 <= N <= 500");
- int a = int.Parse(Console.ReadLine());
- while (a < 0 || a > 500)
- {
- Console.WriteLine("Invalid number! Try again.");
- a = int.Parse(Console.ReadLine());
- continue;
- }
- Console.WriteLine("Please enter a floating-point number N");
- float b = float.Parse(Console.ReadLine());
- Console.WriteLine("Please enter a floating-point number N");
- float c = float.Parse(Console.ReadLine());
- Console.Write("|" + Convert.ToString(a, 16).PadRight(10).ToUpper());
- Console.Write("|" + Convert.ToString(a, 2).PadLeft(10, '0'));
- bool floatCheckB = Convert.ToString(b).IndexOf(".") > 0;
- Console.Write(floatCheckB ? "|{0,10:0.00}" : "|{0,10}", b);
- bool floatCheckC = Convert.ToString(c).IndexOf(".") > 0;
- Console.WriteLine(floatCheckC ? "|{0,-10:0.000}|" : "|{0,-10}|", c);
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement