desislava_topuzakova

Untitled

May 1st, 2020
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 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 x = Integer.parseInt(scanner.nextLine());
  8. double y = Double.parseDouble(scanner.nextLine());
  9. int z = Integer.parseInt(scanner.nextLine());
  10. int workers = Integer.parseInt(scanner.nextLine());
  11.  
  12. double Grapes = x * y;
  13. double Wine = (0.4 * Grapes) / 2.5;
  14. double Wine1 = Math.abs(z - Wine);
  15. double WinePerWorker = Wine1 / workers;
  16.  
  17. if (Wine < z) {
  18. System.out.printf("It will be a tough winter! More %.0f liters wine needed.", Math.floor(Wine1));
  19. } else {
  20. System.out.printf("Good harvest this year! Total wine: %.0f liters.%n %.0f liters left -> %.0f liters per person.", Math.floor(Wine), Math.ceil(Wine1), Math.ceil(WinePerWorker));
  21. }
  22. }
  23. }
Add Comment
Please, Sign In to add comment