Anzzhhela98

edw

Jul 19th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exam_4
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int countBalls = int.Parse(Console.ReadLine());
  10.             int redBalls = 0;
  11.             int orangeBalls = 0;
  12.             int yellowBalls = 0;
  13.             int whiteBalls = 0;
  14.             int blackBalls = 0;
  15.             int balls = 0;
  16.             int other = 0;
  17.             for (int i = 1; i <= countBalls; i++)
  18.             {
  19.                 string colors = Console.ReadLine();
  20.                 if (colors=="red")
  21.                 {
  22.                     redBalls ++;
  23.                     balls +=5;
  24.                 }
  25.                 else if (colors == "orange")
  26.                 {
  27.                     orangeBalls++;
  28.                     balls += 10;
  29.                 }
  30.                 else if (colors == "yellow")
  31.                 {
  32.                     yellowBalls ++;
  33.                     balls += 15;
  34.                 }
  35.                 else if (colors == "white")
  36.                 {
  37.                    whiteBalls ++;
  38.                     balls += 20;
  39.                 }
  40.                else  if (colors=="black")
  41.                 {
  42.                     blackBalls++;
  43.                     balls /= 2;
  44.                 }
  45.                 if (colors!="black"&&colors!="orange"&&colors!="yellow" && colors != "red" && colors != "white")
  46.                 {
  47.                     other++;
  48.                     continue;
  49.                 }
  50.  
  51.                
  52.            
  53.  
  54.  
  55.             }
  56.  
  57.             Console.WriteLine($"Total points: {balls}");
  58.             Console.WriteLine($"Points from red balls: {redBalls}");
  59.             Console.WriteLine($"Points from orange balls: {orangeBalls}");
  60.             Console.WriteLine($"Points from yellow balls: {yellowBalls}");
  61.             Console.WriteLine($"Points from white balls: {whiteBalls}");
  62.             Console.WriteLine($"Other colors picked: {other}");
  63.             Console.WriteLine($"Divides from black balls: {blackBalls}");
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment