모호한 것인지 모르겠지만 내 주요 목표는 사용자에게 일련의 단어 (주어진 금액)를 묻는 메시지를 작성한 다음 어느 것이 먼저 왔는지 알려주는 프로그램을 만드는 것입니다. 알파벳으로 끝나며 가장 짧고 길다. 지금까지 나는이있다 : 길이에 대한스캐너 입력에서 getNewArrayFrom 메서드를 사용하는 방법을 알아낼 수 없습니까?
public static void main(String[] args)
{
Scanner Keyboard = new Scanner(System.in);
double[] Words = getNewArrayFrom(Keyboard);
displayList(Words);
int choice = 1;
while(choice > 0)
{
System.out.println("What would you like to do?");
System.out.println("1) Enter a new list of up to over 9000 words.");
System.out.println("2) Find the shortest, longest, and first and last alphabetically from the list.");
System.out.println("0) Exit the Program");
choice = Integer.parseInt(Keyboard.nextLine());
if(choice < 0 || choice > 2)
{
System.out.println("Invalid Choice Number " + choice);
choice = 1;
continue;
}
if(choice == 1)
{
//Enter the Words one at a time
System.out.println("Enter each of the words.");
for(int i = 0; i < 9001; i++)
{
System.out.print((i+1) + "> ");
Words = Keyboard.nextLine();
Words = getNewArrayFrom(Keyboard);
}
}
else if(choice == 2)
{
}
}
}
}
미안하지만 난 내가 뭘하는지 모르겠어요. 나는이 모든 것을 기억에서 썼고, 나는 무엇을해야할지 정말로 모른다.
필자가 가장 중요한 것은 getNewArrayFrom() 메서드가 선택된 경우 입력 문자열에서 배열을 만들 수 있도록하는 것입니다. 가장 짧고 긴 단어와 첫 번째와 마지막 알파벳 글자를 인쇄하는 방법이나 방향에 대해 나에게 적어도 가르쳐 줄 수 있다면 나는 영원히 위대한 존재가 될 것이다!
죄송합니다. 제 첫 번째 언어가 아닙니다.
"getNewArrayFrom()"함수에 대한 코드가 있습니까? 나는 당신이 그 기능을 만드는 데 도움을 요청하거나 당신이 그걸 만들었지 만 그것으로 오류가 있다면 당신의 게시물에서 확신하지 못했습니다. 당신은 명확히 할 수 있습니까? – kurtzbot
@kurtzbot 아니에요! : P 사실 그 기능을 만들고 스캐너에 적용하는 방법을 묻는 중이었습니다. – MrFribbles
왜 복식 배열을 반환합니까? 'String [] Words = getNewArrayFrom (Keyboard)'을 의미합니까? – kurtzbot