Advertisement
ralichka

Exam.02-03.May-04.Tourist.Shop

Jul 5th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TouristShop
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.  
  11.             string command = Console.ReadLine();
  12.            
  13.             int counter = 1;
  14.             double cost = 0;
  15.  
  16.             while (command != "Stop")
  17.             {
  18.  
  19.                 double price = double.Parse(Console.ReadLine());
  20.            
  21.                 if (counter%3==0)
  22.                 {
  23.                    
  24.                     price/=2;
  25.                
  26.                 }
  27.  
  28.                 if (price > budget)
  29.                 {
  30.  
  31.                     Console.WriteLine($"You don't have enough money!");
  32.                     Console.WriteLine($"You need {(price - budget):f2} leva!");
  33.                     break;
  34.                 }
  35.                 counter++;
  36.                 budget -= price;
  37.                 cost += price;
  38.                
  39.                
  40.                 command = Console.ReadLine();
  41.  
  42.             }
  43.             if (command == "Stop")
  44.             {
  45.                 Console.WriteLine($"You bought {counter-1} products for {cost:f2} leva.");
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement