Advertisement
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 scanner = new Scanner(System.in);
- int vineyard = Integer.parseInt(scanner.nextLine());
- double grapePerSquare = Double.parseDouble(scanner.nextLine());
- int wineNeed = Integer.parseInt(scanner.nextLine());
- int workers = Integer.parseInt(scanner.nextLine());
- double totalGrape = vineyard*grapePerSquare;
- double totalWine = totalGrape*(40.0/100)/2.5;
- if (totalWine >= wineNeed)
- {
- System.out.printf("Good harvest this year! Total wine: %.0f liters.%n", Math.floor(totalWine));
- System.out.printf(" %.0f liters left -> %.0f liters per person.", Math.ceil(totalWine-wineNeed), Math.ceil((totalWine-wineNeed)/workers));
- }
- else
- {
- System.out.printf("It will be a tough winter! More %.0f liters wine needed.", Math.floor(Math.abs(totalWine-wineNeed)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement