Advertisement
bodyquest

partz Invitation

Oct 26th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 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 Party_Invitation
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string inputName = String.Empty;
  14. double countValid = 0;
  15. double countInvalid = 0;
  16. double countAll = 0;
  17.  
  18. while (inputName != "Statistic")
  19. {
  20. inputName = Console.ReadLine();
  21. if (inputName == "Statistic")
  22. {
  23. break;
  24. }
  25. countAll++;
  26. if (inputName.All(char.IsLetter))
  27. {
  28. countValid++;
  29. if (inputName != char.ToUpper(inputName[0]) + inputName.Substring(1).ToLower())
  30. {
  31. inputName = char.ToUpper(inputName[0]) + inputName.Substring(1).ToLower();
  32. Console.WriteLine(inputName);
  33. }
  34. else
  35. {
  36. Console.WriteLine(inputName);
  37. }
  38.  
  39. }
  40. else
  41. {
  42. countInvalid++;
  43. Console.WriteLine("Invalid name!");
  44. }
  45.  
  46. }
  47. Console.WriteLine($"Valid names are {(countValid/countAll*100):f2}% from {countAll} names.");
  48. Console.WriteLine($"Invalid names are {(countInvalid / countAll * 100):f2}% from {countAll} names.");
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement