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 x = Integer.parseInt(scanner.nextLine());
- double y = Double.parseDouble(scanner.nextLine());
- int z = Integer.parseInt(scanner.nextLine());
- int workers = Integer.parseInt(scanner.nextLine());
- double Grapes = x * y;
- double Wine = (0.4 * Grapes) / 2.5;
- double Wine1 = Math.abs(z - Wine);
- double WinePerWorker = Wine1 / workers;
- if (Wine < z) {
- System.out.printf("It will be a tough winter! More %.0f liters wine needed.", Math.floor(Wine1));
- } else {
- System.out.printf("Good harvest this year! Total wine: %.0f liters.%n %.0f liters left -> %.0f liters per person.", Math.floor(Wine), Math.ceil(Wine1), Math.ceil(WinePerWorker));
- }
- }
- }
Add Comment
Please, Sign In to add comment