Advertisement
Guest User

Harvest - Antonia (clear code)

a guest
Feb 20th, 2018
45
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. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int x = int.Parse(Console.ReadLine());          // ==\\
  8.         decimal y = decimal.Parse(Console.ReadLine());  //    ===> complex names are unnecessary
  9.         int z = int.Parse(Console.ReadLine());          // ==//
  10.         int workers = int.Parse(Console.ReadLine());
  11.  
  12.         decimal wine = x * 0.4m * y / 2.5m;
  13.         decimal wineleft = Math.Abs(wine - z); // fist calculating remainding wine
  14.         decimal wineworker = wineleft / workers; // then wineworkers
  15.  
  16.         if (wine >= z) // not (wine > z)
  17.         {
  18.             Console.WriteLine("Good harvest this year! Total wine: {0} liters.",
  19.                 Math.Floor(wine)); // not Math.Ceiling()
  20.  
  21.             Console.WriteLine("{0} liters left -> {1} liters per person.",
  22.                 Math.Ceiling(wineleft), Math.Ceiling(wineworker)); // not Math.Floor()
  23.         }
  24.         else // just else - without condition
  25.         {
  26.             Console.WriteLine("It will be a tough winter! More {0} liters wine needed.",
  27.                 Math.Floor(wineleft)); // not Math.Round()
  28.         }
  29.         // no need return at the end
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement