Advertisement
SUni2020

Harvest

Mar 25th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 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. int vineyard = Integer.parseInt(scanner.nextLine());
  8. double grapePerSquare = Double.parseDouble(scanner.nextLine());
  9. int wineNeed = Integer.parseInt(scanner.nextLine());
  10. int workers = Integer.parseInt(scanner.nextLine());
  11.  
  12. double totalGrape = vineyard*grapePerSquare;
  13. double totalWine = totalGrape*(40.0/100)/2.5;
  14.  
  15. if (totalWine >= wineNeed)
  16. {
  17. System.out.printf("Good harvest this year! Total wine: %.0f liters.%n", Math.floor(totalWine));
  18. System.out.printf(" %.0f liters left -> %.0f liters per person.", Math.ceil(totalWine-wineNeed), Math.ceil((totalWine-wineNeed)/workers));
  19. }
  20. else
  21. {
  22. System.out.printf("It will be a tough winter! More %.0f liters wine needed.", Math.floor(Math.abs(totalWine-wineNeed)));
  23. }
  24.  
  25.  
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement