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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.