메시지를 최대 80 자까지 읽는 프로그램을 만들고 있으며 푸시, 팝 및 비어있는 방법을 사용하여 사용자에게 다시 표시합니다. 유일한 문제는 줄에 단일 변수가 인쇄되므로 한 번에 한 문자 씩 아래쪽으로 화면 아래쪽으로 메시지가 이동한다는 것입니다. 아래 코드는 누군가 올바른 명령이나 해결해야 할 사항을 말해 줄 수 있습니까?한 줄에 여러 변수를 표시 하시겠습니까?
public class StackUser
{
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args)
{
int length;
int I = 0;
char currChar;
int Max = 80;
myStack Placeholder;
Placeholder = new myStack();
System.out.println("Please enter any word or sentence up to a maximum of 80 characters long.");
String userEnter = keyboard.nextLine();
length = userEnter.length();
if (length < Max)
{
while (I < length)
{
char res = userEnter.charAt(I);
Placeholder.PushChar(res);
I = I + 1;
}
}
if (Max < length)
{
while (I < Max)
{
char res = userEnter.charAt(I);
Placeholder.PushChar(res);
I = I + 1;
}
}
while (Placeholder.IsEmpty() != true)
{
currChar = Placeholder.PopChar();
System.out.println("Here is your message backwards:" + currChar);
}
}
}
을'대신'println' 당신이 당신의 메시지 포맷 인쇄 할 –
의 print'? – crAlexander