Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public static double GetAverage()
  2. {
  3. int count = 0, sum = 0;
  4. int x = int.Parse(Console.ReadLine());
  5. while (x != -1)
  6. {
  7. count++;
  8. sum = sum + x;
  9. x = int.Parse(Console.ReadLine());
  10. }
  11. if (count < 100)
  12. return 0;
  13. return ((double)sum / count);
  14. }
  15.  
  16. public static bool GoodDay(double[] a)
  17. {
  18. for (int i = 0; i < a.Length – 1 ; i++)
  19. if (a[i] > 8 && a[i + 1] > 8)
  20. return false;
  21. return true;
  22. }
  23.  
  24. public static void Main()
  25. {
  26. double[] arr = new double[12];
  27. for (int i = 0; i < arr.Length; i++)
  28. {
  29. arr[i] = GetAverage();
  30. }
  31. if (GoodDay(arr) == true)
  32. Console.WriteLine("Good day");
  33. else
  34. Console.WriteLine("Not good day");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement