Advertisement
markopizzy

Untitled

Sep 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import apple.laf.JRSUIConstants;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Harvest {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int area = Integer.parseInt(scanner.nextLine());
  10.         double grapePerMeter = Double.parseDouble(scanner.nextLine());
  11.         int wineNeeded = Integer.parseInt(scanner.nextLine());
  12.         int workers = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double totalWine = area * grapePerMeter * 0.4 / 2.5;
  15.         double difference = totalWine - wineNeeded;
  16.  
  17.         if (totalWine < wineNeeded) {
  18.             System.out.printf("It will be a tough winter! More %.0f liters wine needed.", Math.floor(wineNeeded - totalWine));
  19.  
  20.  
  21.         }else if (totalWine >= wineNeeded) {
  22.             System.out.printf("Good harvest this year! Total wine: %.0f liters.\n", Math.floor(totalWine));
  23.             System.out.printf("%.0f liters left -> %.0f liters per person.", Math.ceil(totalWine - wineNeeded), Math.ceil(difference / workers));
  24.         }
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement