ellapt

T14.11.PrintInDifferentFotmats

Feb 3rd, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System;
  2.  
  3. class PrintInDifferentFotmats
  4. {
  5. static void Main()
  6. {
  7. Console.WriteLine("Read number, print aligned right in 15 symbols as decimal, hexadecimal n,\n% and scientific notation");
  8. int n;
  9. string inputn;
  10. do
  11. {
  12. Console.Write("Enter a number: ");
  13. }
  14. while(!int.TryParse(inputn=Console.ReadLine(), out n));
  15.  
  16. Console.WriteLine("Decimal:");
  17. Console.WriteLine("{0,15}", n);
  18. Console.WriteLine("Hexadecimal:");
  19. Console.WriteLine("{0,15:X}", n);
  20. double nPercent=((double)(n))/100;
  21. Console.WriteLine("Percentage:");
  22. Console.WriteLine("{0,15:P}", nPercent);
  23. Console.WriteLine("Scientific:");
  24. Console.WriteLine("{0,15:E}", n);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment