Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. int n, rand, count = 0, count1 = 0, count2 = 0;
  2. double avg;
  3. Console.WriteLine("enter a full number n");
  4. n = int.Parse(Console.ReadLine());
  5. Random randNum = new Random();
  6. for (int i = 1; i <= n; i++)
  7. {
  8. rand = randNum.Next(8, 11);
  9.  
  10. if (rand == 8)
  11. count++;
  12.  
  13. if (rand == 9)
  14. count1++;
  15.  
  16. if (rand == 10)
  17. count2++;
  18.  
  19. }
  20. if((count > count1) && (count > count2))
  21. Console.WriteLine("8");
  22.  
  23. if((count1 > count) && (count1 > count2))
  24. Console.WriteLine("9");
  25.  
  26. if((count2 > count1)&&(count2 >count))
  27. Console.WriteLine("10");
  28.  
  29. avg = (count * 8 + count1 * 9 + count2 * 10) / n;
  30. Console.WriteLine(avg);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement