67 248
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #3808 in AJAX | JavaScript | HTML | PHP for MohammadAnbar

Question #3808
Write a method in Java which is passed a character (recursion) that prints all characters between ‘a’ and that character.

For example user entered: f ......... then the output should be: abcdef
Expert's answer
import java.io.IOException;public class recurs {

public static void main(String[] args){
char c = 'z';
System.out.print("Enter character from a to z: ");
try {
c = (char)System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
rec_print('a',c);
}
static void rec_print(char from, char to)
{
System.out.print(from);
from++;
if (from <= to) rec_print(from,to);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions