Advertisement
aggressiveviking

Untitled

Feb 19th, 2020
123
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 _06.EasterDecoration
  4. {
  5.     class 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.  
  18.                 while (command != "Finish")
  19.                 {
  20.                     productCount++;
  21.  
  22.                     if (command == "basket")
  23.                     {
  24.                         price += 1.50;
  25.                     }
  26.                     else if (command == "wreath")
  27.                     {
  28.                         price += 3.80;
  29.                     }
  30.                     else if (command == "chocolate bunny")
  31.                     {
  32.                         price += 7;
  33.                     }
  34.                    
  35.                     command = Console.ReadLine();
  36.                 }
  37.  
  38.                 if (productCount % 2 == 0)
  39.                 {
  40.                     double discount = price * 0.2;
  41.                     price -= discount;
  42.                 }
  43.                
  44.                 Console.WriteLine($"You purchased {productCount} items for {price:F2} leva.");
  45.                 totalPrice += price;
  46.             }
  47.  
  48.             Console.WriteLine($"Average bill per client is: {totalPrice / clients:F2} leva.");
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement