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