(Solved) : Write Program Stores Phrase Array Words Prints Backwards Main Method Calls Method Getinput Q42690670 . . .

Write a program that stores a phrase as an array of words, andthen prints it backwards. The main method calls method getInput ,which asks the user how many words there are, stores them in anarray, and returns this array. printBackwards then takes this arrayof words, and prints it in reverse.

Code Example:

import java.util.Scanner;
public class L17Num1{
  
public static void main(String[] args) {
  
String[] sArray=getInput();
printBackwards(sArray);

}
public static String[] getInput()
{
System.out.println(“How many words are there?”);
Scanner scnr = new Scanner(System.in);
int num=scnr.nextInt();
String[] words = new String[num];
for (int i=0;i<num;i++){
words[i] = scnr.nextLine();
}
return words;
}

public static void printBackwards(String []w)
{
for(int i=0;i<w.length;i++)
System.out.println(w[i]);
}
}

Expert Answer


Answer to Write a program that stores a phrase as an array of words, and then prints it backwards. The main method calls method ge…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?