Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BobiZadacha
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double totalMoneySpent = 0;
  10.  
  11.             int clientsCount = int.Parse(Console.ReadLine());
  12.             for (int i = 0; i < clientsCount; i++)
  13.             {
  14.                 int currentBuyerItemsBought = 0;
  15.                 double currentBuyerBill = 0;
  16.  
  17.                 while (true)
  18.                 {
  19.                     string input = Console.ReadLine();
  20.                     if(input == "Finish")
  21.                     {
  22.                         break;
  23.                     }
  24.  
  25.                     if(input == "basket")
  26.                     {
  27.                         currentBuyerBill += 1.50;
  28.                         currentBuyerItemsBought++;
  29.                     }
  30.                     else if(input == "wreath")
  31.                     {
  32.                         currentBuyerBill += 3.80;
  33.                         currentBuyerItemsBought++;
  34.                     }
  35.                     else if(input == "chocolate bunny")
  36.                     {
  37.                         currentBuyerBill += 7.00;
  38.                         currentBuyerItemsBought++;
  39.                     }
  40.                 }
  41.  
  42.                 if(currentBuyerItemsBought % 2 == 0)
  43.                 {
  44.                     currentBuyerBill *= 0.8;
  45.                 }
  46.  
  47.                 totalMoneySpent += currentBuyerBill;
  48.                 Console.WriteLine($"You purchased {currentBuyerItemsBought} items for {currentBuyerBill:f2} leva.");
  49.             }
  50.  
  51.             double averageBill = totalMoneySpent / clientsCount;
  52.  
  53.             Console.WriteLine($"Average bill per client is: {averageBill} leva.");
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement