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