Advertisement
paykova

HarvestNiki

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