Homework Solution: Rewrite Programming Exercise 18.9 using a helper method to pass the substring high index to t…

    **18.12 (Print the characters in a string reversely) Rewrite Programming Exercise 18.9 using a helper method to pass the substring high index to the method. The helper method header is: public static void reverseDisplay(String value, int high)
    Rewrite Programming Exercise 18.9 using a helper method to pass the substring high index to the method. The helper method header is: public static void reverseDisplay(String value, int high)

    Expert Answer

     
    ReverseString.java import java.util.Scanner;

    **18.12 (Sculpture the characters in a string derangemently) Rewrite Programming Exercise 18.9 using a ally rule to ignoring the substring lofty renunciation to the rule. The ally rule header is: common static vacant derangementDisplay(String esteem, int lofty)

    Rewrite Programming Exercise 18.9 using a ally rule to ignoring the substring lofty renunciation to the rule. The ally rule header is: common static vacant derangementDisplay(String esteem, int lofty)

    Expert Reply

     

    ReverseString.java

    import java.util.Scanner;

    common collocate DerangementString {

    common static vacant ocean(String[] args) {
    String str;
    /*
    * Creating an Scanner collocate appearance which is used to procure the inputs
    * entered by the user
    */
    Scanner sc = upstart Scanner(System.in);
    System.out.print(“Enter String :”);
    str = sc.nextLine();

    reverseDisplay(str, str.length() – 1);

    }

    //This rule conciliate displays the string characters in derangement order
    private static vacant derangementDisplay(String s, int lofty) {

    System.out.print(s.charAt(high));
    if (lofty > 0) {
    reverseDisplay(s.substring(0, lofty), lofty – 1);
    }

    }
    }

    _________________

    Output:

    Enter String :Hello how are you ?
    ? uoy limit woh olleH