Aliendreamer

gameofintervals

Mar 18th, 2017
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 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 issue4GameofIntervals
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int moves = int.Parse(Console.ReadLine());
  15.  
  16.            
  17.             double score = 0;
  18.             double low = 0;
  19.             double middle = 0;
  20.             double  average = 0;
  21.             double high = 0;
  22.             double above = 0;
  23.             double invalidnum = 0;
  24.  
  25.             for (int i = 1; i <= moves; i++)
  26.             {
  27.                 double numbers =double.Parse(Console.ReadLine());
  28.  
  29.  
  30.                 if (0 <= numbers && numbers <= 9)
  31.                 {
  32.                     low++;
  33.                     score += numbers * 0.2;
  34.                 }
  35.                 else if (10 <= numbers && numbers <= 19)
  36.                 {
  37.                     middle++;
  38.                     score += numbers * 0.3;
  39.                 }
  40.                 else if (20 <= numbers && numbers <= 29)
  41.                 {
  42.                     average++;
  43.                     score += numbers * 0.4;
  44.                 }
  45.                 else if (30 <= numbers && numbers <= 39)
  46.                 {
  47.                     high++;
  48.                     score += 50;
  49.                 }
  50.                 else if (40 <= numbers && numbers <= 50)
  51.                 {
  52.                     above++;
  53.                     score += 100;
  54.                 }
  55.                 else
  56.                 {
  57.                     invalidnum++;
  58.                     score = score / 2;
  59.  
  60.                 }
  61.             }
  62.                 double lowtotal = (low / moves) * 100;
  63.                 double middletotal = (middle / moves) * 100;
  64.                 double averagetotal = (average / moves) * 100;
  65.                 double hightotal = (high / moves) * 100;
  66.                 double abovetotal = (above / moves) * 100;
  67.                 double invalidnumtotal = (invalidnum / moves) * 100;
  68.  
  69.                 Console.WriteLine("{0:f2}",score);
  70.                 Console.WriteLine("From 0 to 9: {0:f2}%",lowtotal);
  71.                 Console.WriteLine("From 10 to 19: {0:f2}%",middletotal);
  72.                 Console.WriteLine("From 20 to 29: {0:f2}%",averagetotal);
  73.                 Console.WriteLine("From 30 to 39: {0:f2}%",hightotal);
  74.                 Console.WriteLine("From 40 to 50: {0:f2}%", abovetotal);
  75.                 Console.WriteLine("Invalid numbers: {0:f2}%", invalidnumtotal);
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment