Advertisement
Daten

04. Balls

Mar 12th, 2018
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 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 Balls
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var n = int.Parse(Console.ReadLine());
  14.  
  15.             double points = 0;
  16.             var redball = 0;
  17.             var orangeball = 0;
  18.             var yellowball = 0;
  19.             var whiteball = 0;
  20.             var blackball = 0;
  21.             var otherball = 0;
  22.  
  23.             for (int i = 1; i <= n; i++)
  24.             {
  25.                 string color = Console.ReadLine().ToLower();
  26.                 if (color == "red")
  27.                 {
  28.                     points += 5;
  29.                     redball++;
  30.                 }
  31.                 if (color == "orange")
  32.                 {
  33.                     points += 10;
  34.                     orangeball++;
  35.                 }
  36.                 if (color == "yellow")
  37.                 {
  38.                     points += 15;
  39.                     yellowball++;
  40.                 }
  41.                 if (color == "white")
  42.                 {
  43.                     points += 20;
  44.                     whiteball++;
  45.                 }
  46.                 if (color == "black")
  47.                 {
  48.                     points /= 2;
  49.                     blackball++;
  50.                 }
  51.                 if (color != "red" && color != "orange" && color != "yellow" && color != "white" && color != "black")
  52.                 {
  53.                     otherball++;
  54.                 }
  55.             }
  56.  
  57.             Console.WriteLine("Total points: {0}", (int)points);
  58.             Console.WriteLine("Points from red balls: {0}", redball);
  59.             Console.WriteLine("Points from orange balls: {0}", orangeball);
  60.             Console.WriteLine("Points from yellow balls: {0}", yellowball);
  61.             Console.WriteLine("Points from white balls: {0}", whiteball);
  62.             Console.WriteLine("Other colors picked: {0}", otherball);
  63.             Console.WriteLine("Divides from black balls: {0}", blackball);
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement