ralitsa_d

Harvest

Feb 8th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.regex.Matcher;
  3.  
  4. public class P03Harvest {
  5. public static void main(String[] args) {
  6. Scanner scan = new Scanner(System.in);
  7.  
  8. double area = Double.parseDouble(scan.nextLine());
  9. double grapesPerSqM = Double.parseDouble(scan.nextLine());
  10. double neededWine = Double.parseDouble(scan.nextLine());
  11. double workers = Double.parseDouble(scan.nextLine());
  12.  
  13. double totalGrapes = area * grapesPerSqM;
  14. double producedWine = (totalGrapes * 40 / 100) / 2.5;
  15.  
  16. if(producedWine >= neededWine){
  17. System.out.printf("Good harvest this year! Total wine: %s liters.\n", (int)Math.floor(producedWine));
  18. double leftWine = (producedWine - neededWine);
  19. int wineForWorker = (int)Math.ceil(leftWine / workers);
  20.  
  21. System.out.printf("%s liters left -> %s liters per person.",
  22. (int)Math.ceil(leftWine), wineForWorker);
  23. } else {
  24. System.out.printf("It will be a tough winter! More %s liters wine needed.",
  25. (int)Math.floor(neededWine - producedWine));
  26. }
  27. }
  28. }
Add Comment
Please, Sign In to add comment