Advertisement
Ivakis

Реколта

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