Advertisement
RadoslavStamboliev

Problem 04 - Game Of Intervals

Jul 31st, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 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 Game_Of_Intervals
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var result = 0.0;
  14.             var result1 = 0.0;
  15.             var result2 = 0.0;
  16.             var result3 = 0.0;
  17.             var result4 = 0.0;
  18.             var result5 = 0.0;
  19.             var result6 = 0.0;
  20.             int numberOfRounds = int.Parse(Console.ReadLine());
  21.             for (int i = 0; i < numberOfRounds; i++)
  22.             {
  23.                 int points = int.Parse(Console.ReadLine());
  24.  
  25.                 if (points >= 0 && points <= 9)
  26.                 {
  27.                     result += points * 0.2;
  28.                     result1++;
  29.                    
  30.                 }
  31.                 else if (points > 9 && points <= 19)
  32.                 {
  33.                     result += points * 0.3;
  34.                     result2++;
  35.                 }
  36.                 else if (points > 19 && points <= 29)
  37.                 {
  38.                     result += points * 0.4;
  39.                     result3++;
  40.                 }
  41.                 else if (points > 29 && points <= 39)
  42.                 {
  43.                     result += 50.0;
  44.                     result4++;
  45.                 }
  46.                 else if (points > 39 && points <= 50)
  47.                 {
  48.                     result += 100.0;
  49.                     result5++;
  50.                 }
  51.                 else if (points < 0 || points > 50)
  52.                 {
  53.                     result = result / 2.0;
  54.                     result6++;
  55.                 }
  56.        
  57.             }
  58.            
  59.             Console.WriteLine(result);
  60.             Console.WriteLine("From 0 to 9: {0:F2}%", result1/numberOfRounds*100);
  61.             Console.WriteLine("From 10 to 19:  {0:F2}%", result2/numberOfRounds * 100);
  62.             Console.WriteLine("From 20 to 29:  {0:F2}%", result3 /numberOfRounds  * 100);
  63.             Console.WriteLine("From 30 to 39:  {0:F2}%", result4 /numberOfRounds  * 100);
  64.             Console.WriteLine("From 40 to 50:  {0:F2}%", result5 /numberOfRounds  * 100);
  65.             Console.WriteLine("Invalid numbers: {0:F2}%", result6 /numberOfRounds  * 100);
  66.         }
  67.  
  68.         }
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement