Advertisement
bullit3189

Party Invitation

Nov 4th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 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 NLoopsPartyInvitation
  8. {
  9. class NLoopsPartyInvitation
  10. {
  11. static void Main(string[] args)
  12. {
  13. string name = Console.ReadLine();
  14.  
  15. int valid = 0;
  16. int invalid = 0;
  17. int counter = 0;
  18.  
  19.  
  20.  
  21.  
  22. while (name != "Statistic")
  23. {
  24. bool validName = true;
  25. counter++;
  26.  
  27. foreach (char letter in name)
  28. {
  29. if (letter >='a' && letter <='z' || letter >= 'A' && letter<='Z')
  30. {
  31. name = name.Substring(0, 1).ToUpper() + name.Substring(1).ToLower();
  32.  
  33.  
  34. }
  35. else
  36. {
  37. name = "Invalid name!";
  38. validName = false;
  39. break;
  40. }
  41.  
  42. }
  43. if (validName== false)
  44. {
  45. invalid++;
  46. }
  47.  
  48. Console.WriteLine(name);
  49.  
  50. name = Console.ReadLine();
  51. }
  52. valid = counter - invalid;
  53.  
  54.  
  55. double percentValid = valid * 100.0/counter;
  56. double percentInvalid = invalid * 100.0 / counter;
  57.  
  58. Console.WriteLine("Valid names are {0:f2}% from {1} names.",percentValid,counter);
  59. Console.WriteLine("Invalid names are {0:f2}% from {1} names.",percentInvalid,counter);
  60.  
  61.  
  62.  
  63. }
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement