Advertisement
Roadstar3

Harvest

Oct 25th, 2019
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Harvest {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double xM2 = Double.parseDouble(scanner.nextLine());
  8.         double yGrapeM2 = Double.parseDouble(scanner.nextLine());
  9.         double zWine = Double.parseDouble(scanner.nextLine());
  10.         double peopleWorks = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double allGrape = xM2 * yGrapeM2;
  13.         double allWine = (allGrape * 0.40) / 2.5;
  14.  
  15.         if (zWine > allWine) {
  16.             double discount = zWine - allWine;
  17.             System.out.printf("It will be a tough winter! More %.0f liters wine needed.",
  18.                     Math.floor(discount));
  19.         } else {
  20.             double discount = allWine - zWine;
  21.             double winePerson = discount / peopleWorks;
  22.             System.out.printf("Good harvest this year! Total wine: %.0f liters.",
  23.                     Math.floor(allWine));
  24.             System.out.println();
  25.             System.out.printf("%.0f liters left -> %.0f liters per person.",
  26.                     Math.ceil(discount), Math.ceil(winePerson));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement