Advertisement
Deiancom

Profit

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