由于正常句子结构中生成的空格,我的字符串描述使控制台崩溃。我正在寻找一些关于为什么会发生这种情况的指导,此外,如果我以错误的方式解决这个问题,我应该如何处理它。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("-/- Job ticket -/-");
Scanner MyScanner = new Scanner (System.in);
String FirstName;
String LastName;
String Phone;
String Address;
String Description;
int ticketNumber;
int orderMonth ;
int orderDay;
int orderYear;
int requestedDay;
int requestedMonth;
int requestedYear;
System.out.println("First Name = ?");
FirstName = MyScanner.next();
System.out.println("Last Name = ?");
LastName = MyScanner.next();
System.out.println("Phone = ?");
Phone = MyScanner.next();
System.out.println("Address = ?");
Address = MyScanner.next();
System.out.println("Description = ?");
Description = MyScanner.next();
System.out.println("Ticket = ?");
ticketNumber = MyScanner.nextInt();
System.out.println("Order Date Month = ?");
orderMonth = MyScanner.nextInt();
System.out.println("Order Date Day");
orderDay = MyScanner.nextInt();
System.out.println("Order Date Year");
orderYear = MyScanner.nextInt();
System.out.println("Requested Date Month");
requestedMonth = MyScanner.nextInt();
System.out.println("Requested Date Day");
requestedDay = MyScanner.nextInt();
System.out.println("Requested Date Year");
requestedYear = MyScanner.nextInt();
System.out.println("=====================================================");
System.out.print("Ticket : ");
System.out.println(ticketNumber);
System.out.print("Customer: ");
System.out.print(FirstName);
System.out.print(" ");
System.out.println(LastName);
System.out.print("Home Phone: ");
System.out.println(Phone);
System.out.print("Order Date: ");
System.out.print(orderMonth);
System.out.print('/');
System.out.print(orderDay);
System.out.print('/');
System.out.println(orderYear);
System.out.print("Requested Date: ");
System.out.print(requestedMonth);
System.out.print('/');
System.out.print(requestedDay);
System.out.print('/');
System.out.println(requestedYear);
System.out.println("-----------------------------------------------------");
System.out.println("Address");
System.out.println(Address);
System.out.println("-----------------------------------------------------");
System.out.println("Description");
System.out.println(Description);
System.out.println("=====================================================");
System.out.println();
}
}