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 vineyardArea = Integer.parseInt(scanner.nextLine());
- double grape = Double.parseDouble(scanner.nextLine());
- int neededWine = Integer.parseInt(scanner.nextLine());
- int workers = Integer.parseInt(scanner.nextLine());
- double totalGrape = vineyardArea * grape;
- double wine = (totalGrape * 0.4) / 2.5;
- if(wine >= neededWine){
- double wineLeft = Math.ceil(wine - neededWine);
- double winePerWorker = 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, winePerWorker);
- }else{
- double wineNeeded = Math.floor(neededWine - 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