Advertisement
fbinnzhivko

01.00 Sweet Dessert

Apr 25th, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         decimal money = decimal.Parse(Console.ReadLine());
  7.         decimal guests = decimal.Parse(Console.ReadLine());
  8.         decimal bananas = decimal.Parse(Console.ReadLine());
  9.         decimal eggs = decimal.Parse(Console.ReadLine());
  10.         decimal berries = decimal.Parse(Console.ReadLine());
  11.  
  12.         decimal portions = (int)guests / 6;
  13.  
  14.         if (guests % 6 != 0)
  15.         {
  16.             portions++;
  17.         }
  18.  
  19.         decimal total = portions * (2 * bananas + 4 * eggs + (decimal)0.2 * berries);
  20.        
  21.         //Output
  22.  
  23.         if (total <= money)
  24.         {
  25.             Console.WriteLine("Ivancho has enough money - it would cost {0:f2}lv.", total);
  26.         }
  27.         else
  28.         {
  29.             Console.WriteLine("Ivancho will have to withdraw money - he will need {0:f2}lv more.", total - money);
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement