Advertisement
Valantina

Club/Exam

Jul 9th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P04_Club
  4. {
  5.     class P04_Club
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double target = double.Parse(Console.ReadLine());
  10.             string cocktail = Console.ReadLine();
  11.             double income = 0.0;
  12.  
  13.             while ("Party!" != cocktail)
  14.             {
  15.                 int quantity = int.Parse(Console.ReadLine());
  16.  
  17.                 int price = quantity * cocktail.Length;
  18.                 double finalPrice = price;
  19.                 if (price % 2 != 0)
  20.                 {
  21.                     finalPrice *= 0.75;
  22.                 }
  23.                 income += finalPrice;
  24.                 target -= finalPrice;
  25.                 if (target <= 0)
  26.                 {
  27.                     break;
  28.                 }
  29.  
  30.                 cocktail = Console.ReadLine();
  31.             }
  32.  
  33.             if ("Party!" == cocktail)
  34.             {
  35.                 Console.WriteLine($"We need {target:F2} leva more.");
  36.             }
  37.             else
  38.             {
  39.                 Console.WriteLine("Target acquired.");
  40.             }
  41.  
  42.             Console.WriteLine($"Club income - {income:F2} leva.");
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement