Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- double priceStar = 5.69;
- double priceAngel = 8.49;
- double priceLights = 11.20;
- double priceWreath = 15.50;
- double priceCandel = 3.59;
- int count = 0;
- double spendMoney = 0;
- double needMoney = 0;
- bool isFinish = false;
- while (true)
- {
- string item = Console.ReadLine();
- double curentPrice = 0;
- if (item == "Finish")
- {
- isFinish = true;
- break;
- }
- if (item == "Star")
- {
- curentPrice = priceStar;
- }
- else if (item == "Angel")
- {
- curentPrice = priceAngel;
- }
- else if (item == "Lights")
- {
- curentPrice = priceLights;
- }
- else if (item == "Wreath")
- {
- curentPrice = priceWreath;
- }
- else if (item == "Candle")
- {
- curentPrice = priceCandel;
- }
- count++;
- if (count % 3 == 0)
- {
- curentPrice -= curentPrice * 0.3;
- }
- if (budget < curentPrice)
- {
- needMoney = curentPrice - budget;
- break;
- }
- budget -= curentPrice;
- spendMoney += curentPrice;
- }
- if (isFinish)
- {
- Console.WriteLine("Congratulations! You bought everything!");
- }
- else
- {
- Console.WriteLine($"Not enough money! You need {needMoney:F2}lv more.");
- }
- Console.WriteLine($"{count} items -> {spendMoney:F2}lv spent.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement