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

Will someone help me debug this problem, please... // Works with StringBuffer cl

ID: 3764269 • Letter: W

Question

Will someone help me debug this problem, please...

// Works with StringBuffer class to create Pig Latin
// Pig Latin is a made-up language in which you
// remove the first letter of a word and attach
// it to the end, along with "ay". For example,
// "Dog" becomes "ogDay"
import javax.swing.*;
public class DebugSeven3
{
public static void main(String[] args)
{
StringBuffer str = new StringBuffer("");
String userEntry;
char first;
userEntry = JOptionPane.showInputDialog(null, "Enter a word " +
"and I will convert it to Pig Latin");
str.insert(1,userEntry);
first = str.charAt(1);
str.deleteCharAt(2);
str.append(first);
str.append("ya");
JOptionPane.showMessageDialog(null,"Pig Latin version: " + str);
}
}

Explanation / Answer

Pl. make following change in the program

str.deleteCharAt(1);

Output will be

Pig Latin version:

nter a word

and I will convert it to Pig LatinEya

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote