Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ProgramingBasicsME.NestedLoops;
- import java.util.Scanner;
- public class P10Profit {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int oneLev = Integer.parseInt(scanner.nextLine());
- int twoLev = Integer.parseInt(scanner.nextLine());
- int fiveLev = Integer.parseInt(scanner.nextLine());
- int totalSum = Integer.parseInt(scanner.nextLine());
- int one = 1;
- int two = 2;
- int five = 5;
- for (int i = 0; i <= oneLev ; i++) {
- for (int j = 0; j <= twoLev ; j++) {
- for (int k = 0; k <= fiveLev ; k++) {
- if (i * one + j * two + five * k == totalSum ){
- System.out.printf("%d * 1 lv. + %d * 2 lv. + %d * 5 lv. = %d lv.%n", i, j, k, totalSum);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement