stoyanoff

Harvest_Mitko

Jun 17th, 2020
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package com.Softuni2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TEST {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int squareGrape = Integer.parseInt(scanner.nextLine());
  10.         double oneSquareGrape = Double.parseDouble(scanner.nextLine());
  11.         int litersNeed = Integer.parseInt(scanner.nextLine());
  12.         int workers = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double allGrape = squareGrape * oneSquareGrape;
  15.         double needGrape = allGrape * 0.40;
  16.         double litersWine = needGrape / 2.5;
  17.  
  18.         if (litersWine >= litersNeed) {
  19.             System.out.printf("Good harvest this year! Total wine: %d liters.\n", (int)Math.floor(litersWine));
  20.             double leftWine = litersWine - litersNeed;
  21.             double oneWorkerWine = leftWine / workers;
  22.             System.out.printf("%d liters left -> %d liters per person.", (int)Math.ceil(leftWine), (int)Math.ceil(oneWorkerWine));
  23.         } else {
  24.             double needWine = litersNeed - litersWine;
  25.             System.out.printf("It will be a tough winter! More %d liters wine needed.",(int)Math.floor(needWine));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment