Advertisement
tsvetelinapasheva

ExcursionSale

Feb 28th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp43
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int seaPacketNum = int.Parse(Console.ReadLine());
  10.             int mountainPacketNum = int.Parse(Console.ReadLine());
  11.             string destination = Console.ReadLine();
  12.             int profit = 0;
  13.             int seaPrice = 680;
  14.             int mountainPrice = 499;
  15.             string choice = " ";
  16.             while (destination != "Stop")
  17.             {
  18.                 choice = destination;
  19.                 if (destination == "sea")
  20.                 {
  21.                     if (seaPacketNum > 0)
  22.                     {
  23.                         seaPacketNum--;
  24.                         profit += seaPrice;
  25.  
  26.                     }
  27.                 }
  28.  
  29.                 else if (destination == "mountain")
  30.                 {
  31.                     if (mountainPacketNum > 0)
  32.                     {
  33.  
  34.                         mountainPacketNum--;
  35.                         profit += mountainPrice;
  36.                     }
  37.                 }
  38.                
  39.                 if (seaPacketNum == 0 && mountainPacketNum == 0)
  40.                 {
  41.                     break;
  42.                 }
  43.  
  44.                 destination = Console.ReadLine();
  45.             }
  46.             if (seaPacketNum == 0 && mountainPacketNum == 0)
  47.             {
  48.                 Console.WriteLine("Good job! Everything is sold.");
  49.             }
  50.  
  51.             Console.WriteLine($"Profit: {profit} leva.");
  52.  
  53.         }
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement