Advertisement
NelIfandieva

BachelorParty_Solution

Oct 24th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. namespace BachelorParty
  2. {
  3.  
  4.     using System;
  5.     using System.Collections.Generic;
  6.  
  7.     class StartUp
  8.     {
  9.         static void Main()
  10.         {
  11.             int artistFee = int.Parse(Console.ReadLine());
  12.  
  13.             string input = "The restaurant";
  14.             double totalIncome = 0.00;//10345.67
  15.             int totalGuests = 0;
  16.  
  17.             while(input != "The restaurant is full")
  18.             {
  19.                 input = Console.ReadLine();
  20.                 int guestsNum;
  21.  
  22.                 bool inputIsNum = int.TryParse(input, out guestsNum);
  23.  
  24.                 if(inputIsNum)
  25.                 {
  26.                     if(guestsNum < 5)
  27.                     {
  28.                         totalIncome += guestsNum * 100;
  29.                     }
  30.                     else
  31.                     {
  32.                         totalIncome += guestsNum * 70;
  33.                     }
  34.  
  35.                     totalGuests += guestsNum;
  36.                 }
  37.                 else
  38.                 {
  39.                     if(input == "The restaurant is full")
  40.                     {
  41.                         break;
  42.                     }
  43.                 }
  44.             }
  45.  
  46.             if(totalIncome >= artistFee)
  47.             {
  48.                 Console.Write($"You have {totalGuests} guests and {totalIncome - artistFee} leva left.");
  49.             }
  50.             else
  51.             {
  52.                 Console.Write("You have {0} guests and {1} leva income, but no singer.", totalGuests, totalIncome);
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement