desislava_topuzakova

Untitled

Jan 24th, 2022
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Harvest {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int x = Integer.parseInt(scan.nextLine());
  8. double y = Double.parseDouble(scan.nextLine());
  9. int z = Integer.parseInt(scan.nextLine());
  10. int workers = Integer.parseInt(scan.nextLine());
  11.  
  12. double grape = x * y;
  13. double forWine = (grape / 2.5) * 0.4;
  14. if (forWine >= z) {
  15. double left = (forWine - z);
  16. double winePerWorker = left / workers;
  17. System.out.printf("Good harvest this year! Total wine: %.0f liters.%n", Math.floor(forWine));
  18. System.out.printf("%.0f liters left -> %.0f liters per person.", Math.ceil(left), Math.ceil(winePerWorker));
  19. } else{
  20. double wineNeeded = z - forWine;
  21. System.out.printf("It will be a tough winter! More %.0f liters wine needed.", Math.floor(wineNeeded));
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment