Advertisement
NelIfandieva

BakingCompetition

Oct 30th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp210
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int participants = int.Parse(Console.ReadLine());
  10.             int[] info = new int[3];
  11.             int allBakerySold = 0;
  12.             double totalSumOfCharity = 0.00;
  13.  
  14.             for (int i = 1; i <= participants; i++)
  15.             {
  16.                 string name = Console.ReadLine();
  17.                 info = new int[3];
  18.                 string command = "";
  19.  
  20.                 while(command != "Stop baking!")
  21.                 {
  22.                     command = Console.ReadLine();
  23.                     if (command == "Stop baking!")
  24.                     {
  25.                         break;
  26.                     }
  27.  
  28.                     if (command == "cookies")
  29.                     {
  30.                         info[0] = int.Parse(Console.ReadLine());
  31.                         totalSumOfCharity += info[0] * 1.50;
  32.                         allBakerySold += info[0];
  33.                     }
  34.                     else if (command == "cakes")
  35.                     {
  36.                         info[1] = int.Parse(Console.ReadLine());
  37.                         totalSumOfCharity += info[1] * 7.80;
  38.                         allBakerySold += info[1];
  39.                     }
  40.                     else if (command == "waffles")
  41.                     {
  42.                         info[2] = int.Parse(Console.ReadLine());
  43.                         totalSumOfCharity += info[2] * 2.30;
  44.                         allBakerySold += info[2];
  45.                     }
  46.  
  47.                 }
  48.  
  49.                 Console.WriteLine($"{name} baked {info[0]} cookies, {info[1]} cakes and {info[2]} waffles.");
  50.             }
  51.             Console.WriteLine("All bakery sold: {0}", allBakerySold);
  52.             Console.Write("Total sum for charity: {0:f2} lv.", totalSumOfCharity);
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement