dakata450

Untitled

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