Guest User

Untitled

a guest
Jul 20th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. class Harvest
  4. {
  5. static void Main()
  6. {
  7. int x = int.Parse(Console.ReadLine());
  8. double y = double.Parse(Console.ReadLine());
  9. int z = int.Parse(Console.ReadLine());
  10. int numberOfWorkers = int.Parse(Console.ReadLine());
  11.  
  12. double totalGrapes = x * y;
  13. double totalWine = (totalGrapes * 0.4) / 2.5;
  14. double litersLeft = totalWine - z;
  15. double litersPerPerson = litersLeft / numberOfWorkers;
  16. double wineNeeded = z - totalWine;
  17. double wineNededRounded = Math.Truncate(wineNeeded);
  18. double totalWineFloor = Math.Floor(totalWine);
  19. double litersLeftCeilling = Math.Ceiling(litersLeft);
  20. double litersLeftPerPersonCeilling = Math.Ceiling(litersPerPerson);
  21. if (totalWine > z)
  22. {
  23. Console.WriteLine("Good harvest this year! Total wine: {0} liters.", totalWineFloor);
  24. Console.WriteLine("{0} liters left -> {1} liters per person.", litersLeftCeilling, litersLeftPerPersonCeilling);
  25. }
  26. else
  27. {
  28. Console.WriteLine("It will be a tough winter! More {0} liters wine needed.", wineNededRounded);
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment