Advertisement
hrimar

Harvest - from Exam 17/07/2016 of Programming Basics

Jan 19th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Harvest
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             // Harvest - from Exam 17/07/2016 of Programming Basics
  10.             int x = int.Parse(Console.ReadLine());       //total cb.m.
  11.             double y = double.Parse(Console.ReadLine()); //grape per 1 cb.m.
  12.             int z = int.Parse(Console.ReadLine());      //needed wine
  13.             int n = int.Parse(Console.ReadLine());      //workers
  14.  
  15.             var forWine = 0.4 * x;
  16.             var grape = forWine * y;
  17.             var wine = grape / 2.5;
  18.  
  19.             if (wine < z)
  20.             {
  21.                 var lack = Math.Floor(z - wine);
  22.                 Console.WriteLine($"It will be a tough winter! More {lack} liters wine needed.");
  23.             }
  24.            else if (wine >= z)
  25.             {
  26.                 var rest = Math.Ceiling(wine - z);
  27.                 var winePerPerson = Math.Ceiling(rest / n);
  28.                 Console.WriteLine($"Good harvest this year! Total wine: {wine} liters.");
  29.                 Console.WriteLine($"{rest} liters left -> {winePerPerson} liters per person.");
  30.           }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement