Valantina

MovieStars

Jun 18th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04.Movie_Stars
  4. {
  5.     class P04_MovieStars
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.  
  11.             string command = Console.ReadLine();
  12.             bool endBudget = false;
  13.             while(command != "ACTION")
  14.             {      
  15.                 string actor = command;
  16.                 double salary = 0;
  17.                 if(actor.Length <= 15)
  18.                 {
  19.                    salary = double.Parse(Console.ReadLine());
  20.                 }
  21.                 else
  22.                 {
  23.                     salary = 0.20 * budget;
  24.                 }
  25.                 budget -= salary;
  26.                 if (budget <= 0)
  27.                 {
  28.                    
  29.                     Console.WriteLine($"We need {Math.Abs(budget):f2} leva for our actors.");
  30.                     endBudget = true;
  31.                     break;
  32.                 }
  33.  
  34.                command = Console.ReadLine();
  35.             }
  36.             if (!endBudget)
  37.             {
  38.                 Console.WriteLine($"We are left with {budget:F2} leva.");
  39.             }
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment