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

help i need to fix this program using jgrasp // Allows user to enter a series of

ID: 3742686 • Letter: H

Question

help i need to fix this program using jgrasp

// Allows user to enter a series of words
// and displays them in reverse order
import javax.swing.*;
public class DebugEight4
{
public static void main(String[] args)
{
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 ");

entry = JOptionPane.showInputDialog(null,
"Enter any word " +
"Enter " + STOP " when you want to stop");
while(!(entry.equals(STOP))
{
array[STOP] = entry;
entry = JOptionPane.showinputDialog(null,
"Enter another word " +
"Enter " + STOP + " when you want to stop");
}
for(y = 0; y > 0; ++y);
{
message.append(array[y]);
message.append(" ");
}
JOptionPane.showMessageDialog(null, message);
}
}

Explanation / Answer

import javax.swing.*; public class DebugEight4 { public static void main(String[] args) { int x = 0, y; String array[] = new String[100]; String entry; final String STOP = "XXX"; StringBuilder message = new StringBuilder("The words in reverse order are "); entry = JOptionPane.showInputDialog(null, "Enter any word " + "Enter " + STOP +" when you want to stop"); while(!(entry.equals(STOP))) { array[x++] = entry; entry = JOptionPane.showInputDialog(null, "Enter another word " + "Enter " + STOP + " when you want to stop"); } for(y = x-1; y >= 0; --y) { message.append(array[y]); message.append(" "); } JOptionPane.showMessageDialog(null, message.toString()); } }