Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Money {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int ones = Integer.parseInt(scanner.nextLine());
- int twos = Integer.parseInt(scanner.nextLine());
- int fives = Integer.parseInt(scanner.nextLine());
- int sum = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i <= ones; i++) {
- for (int j = 0; j <= twos ; j++) {
- for (int k = 0; k <=fives; k++) {
- if ((i * 1) + (j * 2) + (k * 5) == sum) {
- System.out.println(String.format("%d * 1 lv. + %d * 2 lv. + %d * 5 lv. = %d lv.", i, j, k, sum));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement