Need Pseduocode for the following program /* Backward String Write a method that
ID: 3780155 • Letter: N
Question
Need Pseduocode for the following program
/* Backward String Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method should display "ytivarg". Demonstrate the method in a program that asks the user to input a string and then passes it to the method. */ import java.util.Scanner; // Needed for the Scanner class public class BackwardsString { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); // Create a Scanner object to read input. String input; // To hold the input // Ask the user to input a string System.out.print("Enter a word: "); input = keyboard.nextLine(); // Demonstrate the method by passing it the inputted string. reverse(input); } /* Method: Accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method displays "ytivarg". */ private static void reverse(String word) { System.out.print("Your word reversed: "); for (int i = 0; i < word.length(); i++) System.out.print(word.charAt(word.length() - 1 - i) ); System.out.println(); } }Explanation / Answer
Here is the pseudo code for you:
Algorithm: StringReverse(string[])
length := length(string)
for i := length to 1
print string[i]
print ' '
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.