Advertisement
Ivakis

Profit

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