Advertisement
Spocoman

03. Harvest

Aug 24th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 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.         int x = Integer.parseInt(scanner.nextLine());
  7.         double y = Double.parseDouble(scanner.nextLine());
  8.         int z = Integer.parseInt(scanner.nextLine());
  9.         int workers = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double wine = 0.4 * x * y / 2.5;
  12.  
  13.         if (wine < z) {
  14.             System.out.printf("It will be a tough winter! More %d liters wine needed.", (int)(z - wine));
  15.         } else {
  16.             System.out.printf("Good harvest this year! Total wine: %d liters.\n", (int)(wine));
  17.             System.out.printf("%d liters left -> %d liters per person.", (int)Math.ceil(wine - z), (int)Math.ceil((wine - z) / workers));
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement