Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
2
Indexable
using System;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {

            int seaCount = int.Parse(Console.ReadLine());
            int moutainCount = int.Parse(Console.ReadLine());

            double seaPrice = 680;
            double mountainPrice = 499;

            double finalProfit = 0;

            while (true)
            {
                string type = Console.ReadLine();
                if (type == "stop")
                {
                    Console.WriteLine("Good job! Everything is sold.");
                    break;
                }
                if (type == "sea" && seaCount != 0)
                {
                    finalProfit += seaPrice;
                    seaCount--;
                }
                else if (type == "mountain" && moutainCount != 0)
                {
                    finalProfit += mountainPrice;
                    moutainCount--;
                }

                if (seaCount == 0)
                    if (moutainCount == 0)
                        break;

                if (moutainCount == 0)
                    if (seaCount == 0)
                        break;
            }

            Console.WriteLine("Good job! Everything is sold.");
            Console.WriteLine($"Profit: {finalProfit} leva.");

        }
    }
}