私は If and else のプロジェクトを行っています。このプロジェクトでは、ユーザー入力を取得し、入力した単語の最初の文字を単語の最後の文字に移動する必要があります。問題は、ユーザーの最後の番号がわからないことです。
これには部分文字列メソッドを使用したいと思います。単語の先頭から単語の最後の文字まで文字を移動する方法がわかりません。単語の最後の文字が何であるかがわからないためです(ユーザーは何でも入力できます)
私はそれを始めましたが、ユーザー入力の最後の文字が何であるかがわからないため、まったく進歩していません。
import javax.swing.*;
public class PigLatinDriver {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String word = JOptionPane.showInputDialog("Enter the word to be translated into pig Latin.");
boolean consonant =false;
If(word.substring(0)== "b");{
word.substring(0).replace("b"," ");
}
if(consonant==true){
}
//perform the logic to translate to piglatin
//Words that begin with a consonant move the first letter to the end and then add ay
// vowels just add ay
// The exception being when you use the word "Small" with an upper case, then you make no change.
String translation = "";
JOptionPane.showMessageDialog(null, translation);
}
private static void If(boolean b) {
// TODO Auto-generated method stub
}
}