我必須製作一個代碼,使得星球大戰名稱生成器和它要求的名稱,但只需要從名稱的某些字母拿出星球大戰的名字,我的程序不會編譯任何人都可以看到什麼即時做錯了:星球大戰名字發生器代碼
import java.util.Scanner;
public class StarWarsName {
public static void main(String[] args) {
System.out.printf("Enter your first name: ");
firstname = input.nextLine();
first = first.substring(0,3);
System.out.printf("Enter your last name: ");
lastname = input.nextLine();
last = last.substring(0,2);
System.out.printf("Enter your mother's maiden name: ");
mothersname = input.nextLine();
mother = mother.substring(0,2);
System.out.printf("Enter the name of the city in which you were born: ");
cityname = input.nextLine();
city = city.substring(0,3);
StarWarsName = first +" "+ last +" "+ mother +" "+ city + " of " + last +" "+$
System.out.println("May the force be with you, " + StarWarsName + "May the fo$
}
}
編譯錯誤發生在哪裏? – Smutje
什麼是「第一」,什麼是「最後」,什麼是「城市」?你在哪裏實例化這些變量? – GameDroids
最好的問題! +1 – PeeHaa