English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

couple problems that i'm stuck with...

1. write a method called average that accepts two integer parameters and returns their average as a floating point value.

2. overload the previous problem such that if three integers are provided as parameters, the method retrns the average of all three.

3. overload the average method of problem 1 to accept four integer parameters and return their average.

4. write a method called multiConcat that takes a String and an integer as parameters. Return a String that consists of the string parameter concatenated with itself count times, where count is the integer parameter. For example, if the parameter values are "hi" and 4, the return value is "hihihihi". Return the original string if the integer parameter is less than 2.

2007-06-25 17:01:49 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

You should do your own homework, especially it is a summer school.

Nevertheless I am going to write #4 out in a certain way:
String multiConcat(String original, int x) {
if (x < 2) return original;
else return original + multiConcat(original, x - 1);
}

2007-06-25 17:17:46 · answer #1 · answered by Andy T 7 · 0 0

fedest.com, questions and answers