DebugEight4: Here is the code that needs to be debugged, I fixed some but it will not display the words in reverse at the end: // Application allows user to enter a series of words // and displays them in reverse order

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question

DebugEight4:

Here is the code that needs to be debugged, I fixed some but it will not display the words in reverse at the end:

// Application allows user to enter a series of words
// and displays them in reverse order
import java.util.*;
public class DebugEight4
{
   public static void main(String[] args)
   {
      Scanner input = new Scanner(System.in);
      int x = 0, y;
      String array[] = new String[100];
      String entry;
      final String STOP = "XXX";
      StringBuffer message = new
          StringBuffer("The words in reverse order are\n");
     
      System.out.println("Enter any word\n" +
      "Enter  + STOP +  when you want to stop");
      entry = input.next();
      while(!(entry.equals(STOP)))
      {
         array[x] = entry;
         ++x;
         System.out.println("Enter another word\n" +
         "Enter " + STOP + " when you want to stop");
         entry = input.next();
      }
      for(y = x - 1; y > 0; ++y)
      {
         message.append(array[y]);
         message.append("\n");
      }
      System.out.println(message);
}
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,