Advertisement
fbinnzhivko

01.00 Cake Tycoon

May 4th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         ulong cakesWanted = ulong.Parse(Console.ReadLine());
  7.         double kilosPerCake = double.Parse(Console.ReadLine());
  8.         uint flourKilos = uint.Parse(Console.ReadLine());
  9.         uint trufles = uint.Parse(Console.ReadLine());
  10.         uint trufflesPrice = uint.Parse(Console.ReadLine());
  11.  
  12.         ulong trufflescost = (ulong)trufles * trufflesPrice;
  13.         double cakesProduced = Math.Floor(flourKilos / kilosPerCake);
  14.  
  15.         if (cakesProduced < cakesWanted)
  16.         {
  17.             double kilogramsNeeded = kilosPerCake * cakesWanted - flourKilos;
  18.             Console.WriteLine("Can make only {0:f0} cakes, need {1:f2} kg more flour", cakesProduced, kilogramsNeeded);
  19.         }
  20.         else
  21.         {
  22.             double cakeCost = (double)trufflescost / cakesWanted * (double)1.25;
  23.             Console.WriteLine("All products available, price of a cake: {0:f2}", cakeCost);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement