This question's due date has already passed. You may post a tutorial, but there's no guarantee that the original asker will purchase the tutorial. But other people might!

Question

# \$15.00Java digital root

Rating :No Rating
Tutorials Posted: 0

Q:

The digital root of an integer is the sum of its digits. If that sum is not a single digit number, the

process is repeated with the sum until a single digit is reached. For example, the digital root of 4726 is 4

+ 7 + 2 + 6 = 19 = 1 + 9 = 10 = 1 + 0 = 1. The iterative version is written as follows:

public static int digitalRoot(int num){

int temp;

while (num > 9){

temp = 0; 2

while (num != 0){

temp += num % 10;

num = num / 10;     // or num /= 10;

}

num = temp;

}

return num;

}

Take the above iterative method and make it recursive; then write a program to test your answer.

• Check values from 1 to 40000.

• Do not use a helper method.

Sample Runs:

Enter a positive integer: 4726

The digital root of 4726 is: 1

Enter a positive integer: 39

The digital root of 39 is: 3

Notes/Hints/Tips:

• The program must be recursive for full credit.

• Get the non-recursive program to work first- then translate to recursion.

Name the program:  RecRootXX.java.process is repeated with the sum until a single digit is reached. For example, the digital root of 4726 is 4
+ 7 + 2 + 6 = 19 = 1 + 9 = 10 = 1 + 0 = 1. The iterative version is written as follows:
public static int digitalRoot(int num){
int temp;
while (num > 9){
temp = 0; 2
while (num != 0){
temp += num % 10;
num = num / 10;     // or num /= 10;
}
num = temp;
}
return num;
}
Take the above iterative method and make it recursive; then write a program to test your answer.
• Check values from 1 to 40000.
• Do not use a helper method.
Sample Runs:
Enter a positive integer: 4726
The digital root of 4726 is: 1
Enter a positive integer: 39
The digital root of 39 is: 3
Notes/Hints/Tips:
• The program must be recursive
• Get the non-recursive program to work first- then translate to recursion.
• Name the program:  RecRoot.java.

Available Tutorials to this Question

\$15.00
Correct A+++ Solution!!! - Digital root of a number
• This tutorial hasn't been purchased yet.
• Posted on Dec. 04, 2012 at 10:32:37AM
Posted by :

Rating (385):A+
Tutorials Posted: 750,
Earned: \$16,344.46

A:
Preview: ... ase find the ...

The full tutorial is about 7 words long plus attachments.

Attachments:
recroot.zip (1K)

RecRoot.class
RecRoot.java
]

screenshot.jpg (35K) (Preview)

\$10.00
A+ solution with screenshot
• This tutorial hasn't been purchased yet.
• Posted on Dec 04, 2012 at 6:35:16PM
Posted by :

Rating (2353):A+
Tutorials Posted: 5427,
Earned: \$110,745.07

A:
Preview: ... ttached ...

The full tutorial is about 12 words long plus attachments.

Attachments:
screenshot_root.jpg (17K) (Preview)
RecRoot.java (1K) (Preview)

\$10.00
A++ solution with Screenshot - RecRoot Java Program - Detailed comment
• This tutorial was purchased 1 time and rated A+ by students like you.
• Posted on Dec 04, 2012 at 7:14:13PM
Posted by :

Rating (308):A-