Advertisement
silvana1303

easter decoration

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