Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the potential limitations of group discussion?

Answered: 1 week ago

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago

Question

How do we organise for international logistics?

Answered: 1 week ago