Advertisement
MladenKarachanov

Harvest

Nov 24th, 2023
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. package ProgrammingBasics2;
  2.  
  3. import java.util.Scanner;
  4.  
  5.  
  6. import java.util.Scanner;
  7.  
  8.     public class Harvest2 {
  9.         public static void main(String[] args) {
  10.             Scanner scanner = new Scanner(System.in);
  11.             int x = Integer.parseInt(scanner.nextLine());
  12.             double y = Double.parseDouble(scanner.nextLine());
  13.             int z = Integer.parseInt(scanner.nextLine());
  14.             int numWorkers = Integer.parseInt(scanner.nextLine());
  15.             double allGrapes = y * x;
  16.             double harvest = 0.40;
  17.             // double oneMeters=y*0.40;
  18.             double oneLiterForGrapes = 2.5;
  19.             double wine =Math.ceil((allGrapes * harvest) / oneLiterForGrapes);
  20.             double sum =Math.abs(wine-z);
  21.             double liters =Math.ceil(sum / numWorkers);
  22.             if (wine < z) {
  23.                 //System.out.println(sum);
  24.                 System.out.printf("It will be a tough winter! More %.0f liters wine needed.",sum);
  25.             }else{
  26.                 System.out.printf("Good harvest this year! Total wine: %.0f liters.",wine);
  27.                 System.out.println();
  28.                 System.out.printf("%.0f liters left -> %.0f liters per person.",sum,liters);
  29.             }
  30.         }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement