o_ignatov

more_exercises_02

Jun 2nd, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem02_numChecker
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. bool canFitInt = false;
  15. try
  16. {
  17. int num = int.Parse(input);
  18. canFitInt = true;
  19. }
  20. catch
  21. {
  22. canFitInt = false;
  23. }
  24. if (canFitInt)
  25. {
  26. Console.WriteLine("integer");
  27. }
  28. else if (input.Contains('.'))
  29. {
  30. Console.WriteLine("floating-point");
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment