Question
I ask again The answer you wrote to me in the previous question does not go through my compilation That's why I've put down included
I ask again The answer you wrote to me in the previous question does not go through my compilation That's why I've put down included the tester's code here as well Maybe you can help me what the problem is here?
I need to write at java a recursive static method that accepts as a parameter a positive integer and returns several
solutions to the equation
x1 + x2 + x3 = digit
The three x's are integers and positive numbers between 1 to 10
The method should also print these solutions (no matter the order of printing)
Example 1:
If digit = 3 returns the value 1 there is only one solution to the equation: x1 = 1, x2 = 1, x3 = 1
And the method will print
output:
1 + 1 + 1
value: 1
Example 2:
If digit = 5 return the value 6 and print the following solutions:
output:
1 + 1 + 3
1 + 2 + 2
1 + 3 + 1
2 + 1 + 2
2 + 2 + 1
3 + 1 + 1
value: 6
The method should be recursive without using loops also any auxiliary method cannot be with loops.
Not used java package
It is possible to use overloading and not have to optimize the method
I started the some code:
this code at class:
public class Question { public static int solutions(int digit){
if (digit <3 || digit> 30)
return 0;
} }
this code at tester main:
public class QuestionTester { public static void main(){ System.out.println("Checking method solutions with number 4 ");
result= Question.solutions(4); System.out.println(); System.out.println("Result is: "+ result); System.out.println(); } }
I would appreciate your assistance
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started