Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 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 _5_easter_eggs
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int red = 0;
  14. int orange = 0;
  15. int blue = 0;
  16. int green = 0;
  17. int max;
  18.  
  19.  
  20. max = int.Parse(Console.ReadLine());
  21.  
  22. while (max < 1 || max > 100)
  23. {
  24. Console.WriteLine("Error");
  25. max = int.Parse(Console.ReadLine());
  26. }
  27.  
  28. for (int counter = 0; counter < max; counter++)
  29. {
  30. string var = Console.ReadLine();
  31. if (var == "red")
  32. {
  33. red++;
  34.  
  35. }
  36. if (var == "green")
  37. {
  38. green++;
  39.  
  40.  
  41. }
  42. if (var == "orange")
  43. {
  44. orange++;
  45.  
  46.  
  47. }
  48. if (var == "blue")
  49. {
  50. blue++;
  51.  
  52. }
  53.  
  54. }
  55.  
  56.  
  57. int max1 = (Math.Max(Math.Max(red , green), Math.Max(orange, blue)));
  58. Console.WriteLine("Red eggs: " + red);
  59. Console.WriteLine("Orange eggs: " + orange);
  60. Console.WriteLine("Blue eggs: " + blue);
  61. Console.WriteLine("Green eggs: " + green);
  62. Console.WriteLine($"Max eggs: {max1} -> blue");
  63.  
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement