Advertisement
CR7CR7

WaterDelivery

Oct 17th, 2022
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class waterDelivery {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scan = new Scanner(System.in);
  7.  
  8.  
  9.         int  numLittleBottles = Integer.parseInt(scan.nextLine());
  10.         int  numBigBottles = Integer.parseInt(scan.nextLine());
  11.         int  capasityTruck = Integer.parseInt(scan.nextLine());
  12.         int bigBottles = numBigBottles;
  13.         while((bigBottles * 5) >  capasityTruck) {
  14.             bigBottles--;
  15.         }
  16.         int neededLittleB = capasityTruck - (bigBottles * 5);
  17.         if(numLittleBottles < neededLittleB)
  18.         {
  19.             System.out.println(-1);
  20.         }
  21.         else {
  22.             System.out.println(neededLittleB);
  23.         }
  24.  
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement