Advertisement
Spocoman

10. Profit

Aug 30th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Profit {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int oneBGNCoinCount = Integer.parseInt(scanner.nextLine()),
  7.                 twoBGNCoinCount = Integer.parseInt(scanner.nextLine()),
  8.                 fiveBGNCoinCount = Integer.parseInt(scanner.nextLine()),
  9.                 sum = Integer.parseInt(scanner.nextLine());
  10.  
  11.         for (int i = 0; i <= oneBGNCoinCount; i++) {
  12.             for (int j = 0; j <= twoBGNCoinCount; j++) {
  13.                 for (int k = 0; k <= fiveBGNCoinCount; k++) {
  14.                     if (i + j * 2 + k * 5 == sum) {
  15.                         System.out.printf("%d * 1 lv. + %d * 2 lv. + %d * 5 lv. = %d lv.\n", i, j, k, sum);
  16.                     }
  17.                 }
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement