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