Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java netbeans 01- Write a java method that computes the number of odd integers i

ID: 3729622 • Letter: J

Question

Java netbeans

01- Write a java method that computes the number of odd integers in an array of integers. Test your method.
02- Write a recursive Java method that takes a character string s and outputs its reverse. For example, the reverse of 'pots&pans' would be 'snap&stop'. Test your method. Java netbeans

01- Write a java method that computes the number of odd integers in an array of integers. Test your method.
02- Write a recursive Java method that takes a character string s and outputs its reverse. For example, the reverse of 'pots&pans' would be 'snap&stop'. Test your method.

01- Write a java method that computes the number of odd integers in an array of integers. Test your method.
02- Write a recursive Java method that takes a character string s and outputs its reverse. For example, the reverse of 'pots&pans' would be 'snap&stop'. Test your method.

Explanation / Answer

1)


public int countOdds (int[] values)

{


int countOdd =0;

for (int i=0; i<values.length; i++)

{

if (values[i] %2 != 0)

{
countOdd++;

}

}

return countOdd;

}

2)

public class Test {

    private static int i = 0;

    public static void main(String args[]) {

        reverse("Hello");

    }

    public static String reverse(String str) {

        int localI = i++;

        if ((null == str) || (str.length() <= 1)) {

            return str;

        }

        System.out.println("Step " + localI + ": " + str.substring(1) + " / " + str.charAt(0));

        String reversed = reverse(str.substring(1)) + str.charAt(0);

        System.out.println("Step " + localI + " returns: " + reversed);

        return reversed;

    }

}

Coded the methods of two questions please get back to me

Thank you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote