Advertisement
Guest User

Untitled

a guest
Oct 13th, 2022
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | Software | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Mock5_mineralWater {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int smallBottles = scanner.nextInt();
  8.         int bigBottles = scanner.nextInt();
  9.         int truckCapacity = scanner.nextInt();
  10.  
  11.         while (bigBottles > 0 && truckCapacity >= 0) {
  12.             if (truckCapacity < 5) {
  13.                 break;
  14.             }
  15.             bigBottles--;
  16.             truckCapacity -= 5;
  17.         }
  18.  
  19.  
  20.         int difference = truckCapacity - smallBottles;
  21.  
  22.         if (difference > 0) {
  23.             System.out.println("-1");
  24.         } else if (difference == 0) {
  25.             System.out.println(smallBottles);
  26.         } else {
  27.             System.out.println(truckCapacity);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement