Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.regex.Matcher;
- public class P03Harvest {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double area = Double.parseDouble(scan.nextLine());
- double grapesPerSqM = Double.parseDouble(scan.nextLine());
- double neededWine = Double.parseDouble(scan.nextLine());
- double workers = Double.parseDouble(scan.nextLine());
- double totalGrapes = area * grapesPerSqM;
- double producedWine = (totalGrapes * 40 / 100) / 2.5;
- if(producedWine >= neededWine){
- System.out.printf("Good harvest this year! Total wine: %s liters.\n", (int)Math.floor(producedWine));
- double leftWine = (producedWine - neededWine);
- int wineForWorker = (int)Math.ceil(leftWine / workers);
- System.out.printf("%s liters left -> %s liters per person.",
- (int)Math.ceil(leftWine), wineForWorker);
- } else {
- System.out.printf("It will be a tough winter! More %s liters wine needed.",
- (int)Math.floor(neededWine - producedWine));
- }
- }
- }
Add Comment
Please, Sign In to add comment