Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp13
- {
- class Program
- {
- static void Main(string[] args)
- {
- int budjet = int.Parse(Console.ReadLine());
- string productName = Console.ReadLine();
- double counter = 0;
- double totalSum = 0;
- double resto = budjet;
- while (productName != "Finish")
- {
- double order = 0;
- switch (productName)
- {
- case "Star":
- order += 5.69;
- counter++;
- break;
- case "Angel":
- order += 8.49;
- counter++;
- break;
- case "Lights":
- order += 11.2;
- counter++;
- break;
- case "Wreath":
- order += 15.5;
- counter++;
- break;
- default:
- order += 3.59;
- counter++;
- break;
- }
- if (counter == 3)
- {
- order -= order * 0.30;
- }
- resto -= order;
- totalSum += order;
- if (resto < order)
- {
- Console.WriteLine($"Not enough money! You need {order - resto:F2}lv more.");
- Console.WriteLine($"{counter} items -> {totalSum:f2}lv spent.");
- return;
- }
- productName = Console.ReadLine();
- }
- if (productName == "Finish")
- {
- Console.WriteLine("Congratulations! You bought everything!");
- Console.WriteLine($"{counter} items -> {totalSum:f2}lv spent.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement