Advertisement
tenachev

Lutenicca

Apr 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Lutenica {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double totalTomato = Double.parseDouble(scanner.nextLine());
  8.         int boxes = Integer.parseInt(scanner.nextLine());
  9.         int jars = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double totalLutenica = 0;
  12.         double jar = 0;
  13.         double box = 0;
  14.         double leftBoxes = 0;
  15.         double leftJars = 0;
  16.  
  17.         totalLutenica = totalTomato / 5;
  18.         jar = totalLutenica / 0.535;
  19.         box = jar / jars;
  20.  
  21.         if (box > boxes){
  22.            leftBoxes = box - boxes;
  23.            leftJars = jar - (boxes * jars);
  24.             System.out.printf("Total lutenica: %.0f kilograms.%n", Math.floor(totalLutenica));
  25.             System.out.printf("%.0f boxes left.%n", Math.floor(leftBoxes));
  26.             System.out.printf("%.0f jars left.%n", Math.floor(leftJars));
  27.         }else if (box < boxes){
  28.             leftBoxes = boxes - box;
  29.             leftJars = (boxes * jars) - jar;
  30.             System.out.printf("Total lutenica: %.0f kilograms.%n", Math.floor(totalLutenica));
  31.             System.out.printf("%.0f more boxes needed.%n", Math.floor(leftBoxes));
  32.             System.out.printf("%.0f more jars needed.%n", Math.floor(leftJars));
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement