Advertisement
veronikaaa86

Profit

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