Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Harvest {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int x = Integer.parseInt(scan.nextLine());
- double y = Double.parseDouble(scan.nextLine());
- int z = Integer.parseInt(scan.nextLine());
- int workers = Integer.parseInt(scan.nextLine());
- double grape = x * y;
- double forWine = (grape / 2.5) * 0.4;
- if (forWine >= z) {
- double left = (forWine - z);
- double winePerWorker = left / workers;
- System.out.printf("Good harvest this year! Total wine: %.0f liters.%n", Math.floor(forWine));
- System.out.printf("%.0f liters left -> %.0f liters per person.", Math.ceil(left), Math.ceil(winePerWorker));
- } else{
- double wineNeeded = z - forWine;
- System.out.printf("It will be a tough winter! More %.0f liters wine needed.", Math.floor(wineNeeded));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment