borkins

Exam 17-Jul-2016 - 02. Harvest

May 16th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. /**
  2.  * Project: Exam_17_July_2016 - created by borkins on 2017-05-16.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _02_Harvest
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.        
  13.         int area = Integer.parseInt(console.nextLine());
  14.         double grapesSqM = Double.parseDouble(console.nextLine());
  15.         double wineNeeded = Double.parseDouble(console.nextLine());
  16.         int workers = Integer.parseInt(console.nextLine());
  17.        
  18.         double totalGrapes = area * grapesSqM;
  19.         double wine = 0.4 * totalGrapes / 2.5;
  20.         double diffWine = Math.abs(wine - wineNeeded);
  21.        
  22.         if (wine >= wineNeeded)
  23.         {
  24.             System.out.printf("Good harvest this year! " +
  25.                               "Total wine: %d liters.%n", (int) wine);
  26.             System.out.printf("%d liters left -> %d liters per person.",
  27.                               (int) Math.ceil(diffWine),
  28.                               (int) Math.ceil(diffWine / workers));
  29.         }
  30.         else {
  31.             System.out.printf("It will be a tough winter! " +
  32.                               "More %d liters wine needed.%n", (int) diffWine);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment