Advertisement
fbinnzhivko

Untitled

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