velikova_olya

Harvest

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