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);
- double xM2 = Double.parseDouble(scanner.nextLine());
- double yGrapeM2 = Double.parseDouble(scanner.nextLine());
- double zWine = Double.parseDouble(scanner.nextLine());
- double peopleWorks = Double.parseDouble(scanner.nextLine());
- double allGrape = xM2 * yGrapeM2;
- double allWine = (allGrape * 0.40) / 2.5;
- if (zWine > allWine) {
- double discount = zWine - allWine;
- System.out.printf("It will be a tough winter! More %.0f liters wine needed.",
- Math.floor(discount));
- } else {
- double discount = allWine - zWine;
- double winePerson = discount / peopleWorks;
- System.out.printf("Good harvest this year! Total wine: %.0f liters.",
- Math.floor(allWine));
- System.out.println();
- System.out.printf("%.0f liters left -> %.0f liters per person.",
- Math.ceil(discount), Math.ceil(winePerson));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement