rossirm

02.Lutenitsa - Задача 2. Лютеница

Nov 6th, 2017
254
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class p02 {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scan = new Scanner(System.in);
  7.  
  8.         double tomatoQuantity = Double.parseDouble(scan.nextLine());
  9.         int countCadges = Integer.parseInt(scan.nextLine());
  10.         int countCups = Integer.parseInt(scan.nextLine());
  11.  
  12.         double total = tomatoQuantity / 5.0;
  13.         System.out.printf("Total lutenica: %.0f kilograms.%n", Math.floor(total));
  14.         double cups = total / 0.535;
  15.         double cadges = (cups / countCups);
  16.         double left = 0.0;
  17.         double result = 0.0;
  18.         if (cadges > countCadges) {
  19.             left = cadges - countCadges;
  20.             result = cups - countCadges * countCups;
  21.             System.out.printf("%.0f boxes left.%n", Math.floor(left));
  22.             System.out.printf("%.0f jars left.", Math.floor(result));
  23.         } else if (cadges < countCadges) {
  24.             left = countCadges - cadges;
  25.             result = (countCadges * countCups) - cups;
  26.             System.out.printf("%.0f more boxes needed.%n", Math.floor(left));
  27.             System.out.printf("%.0f more jars needed.", Math.floor(result));
  28.         }
  29.     }
  30. }
RAW Paste Data