Advertisement
galinyotsev123

ProgBasicsJavaBook3.2SimpleConditions04Harvest

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