Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Simple Java question 6

BunkerHillBroad
BunkerHillBroad 


The following recursive method is supposed to add up the digits of the argument n. For example, digitSum(3456) returns 18 (which is the sum 3+4+5+6). The code has two omissions, indicated by ??? . Replace each ??? with the correct Java code. You may assume the argument n is non-negative. static int digitSum (int n) { if(n<10){return??? ;} //basecase else return ??? ; } Attachments
Tags Clarifications

Answers

Simple Java question 6 - Solution

mariobeka
mariobeka 



Open the solution file with any text editor. Attachments Screenshots
Purchase Answer

ProblemSolution6

uetian_cute
uetian_cute 



Solution to Problem 6.
You can check it by compiling
Attachments
problemSolution6.zip (1 K) Download
Preview
If The solution is Correct * */ System.out.println(digitSum(34)); } static int digitSum (int n) {

Screenshots
Purchase Answer