Advertisement
aggressiveviking

Untitled

Feb 17th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P06_EasterDecoration
  4. {
  5.     class P06_EasterDecoration
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int clients = int.Parse(Console.ReadLine());
  10.             double totalPrice = 0.0;
  11.  
  12.             for (int i = 0; i < clients; i++)
  13.             {
  14.                 string command = Console.ReadLine();
  15.                 double price = 0.0;
  16.                 int productCount = 0;
  17.                 while ("Finish" != command)
  18.                 {
  19.                     productCount++;
  20.                     switch (command)
  21.                     {
  22.                         case "basket":
  23.                             price += 1.50;
  24.                             break;
  25.                         case "wreath":
  26.                             price += 3.80;
  27.                             break;
  28.                         case "chocolate bunny":
  29.                             price += 7;
  30.                             break;
  31.                     }
  32.                     command = Console.ReadLine();
  33.                 }
  34.                 if (productCount % 2 == 0)
  35.                 {
  36.                     double discount = price * 0.2;
  37.                     price -= discount;
  38.                 }
  39.                 Console.WriteLine($"You purchased {productCount} items for {price:F2} leva.");
  40.                 totalPrice += price;
  41.             }
  42.             Console.WriteLine($"Average bill per client is: {totalPrice / clients:F2} leva.");
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement