Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class test {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- int landArea = Integer.parseInt(myScan.nextLine());
- double grapesPerSqMeter = Double.parseDouble(myScan.nextLine());
- int wineForSale = Integer.parseInt(myScan.nextLine());
- int workers = Integer.parseInt(myScan.nextLine());
- double producedGrapes = landArea * grapesPerSqMeter;
- double producedWine = ( producedGrapes * 0.4 )/ 2.5;
- if ( producedWine < wineForSale) {
- double wineShortage = wineForSale - producedWine;
- System.out.printf("It will be a tough winter! More %d liters wine needed.", (int)wineShortage);
- } else {
- double wineExceed = producedWine - wineForSale;
- double winePerWorker = wineExceed / workers;
- System.out.printf("Good harvest this year! Total wine: %d liters.\n", (int)producedWine);
- System.out.printf("%d liters left -> %d liters per person.", (int)Math.ceil(wineExceed), (int)Math.ceil(winePerWorker));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement