我对“模型”扫描仪有疑问。我的程序要求我从预先确定的图表中输入车辆。有些车辆是两个词的例子:“Grand Caravan”。我理解为什么它给了我两个字,因为下一个扫描仪是一个不允许字符的双精度扫描仪,所以它会出错。如果可能的话,我只想在单个扫描仪中包含空格和第二个单词,或者有其他方法吗?
String make, model;
double cityMPG, hwyMPG;
do {
System.out.println("Please enter your cars make"); // asking for cars make
make = keyboard.next();
System.out.println("Enter your cars model"); // asking for cars model
model = keyboard.next();
System.out.println("Enter your gas tank size"); // asking for gas tank size
tanksize = keyboard.nextDouble();
System.out.println("Enter your city MPG"); // asking for City MPG1
cityMPG = keyboard.nextDouble();
System.out.println("Enter your highway MPG"); // asking for Highway MPG
hwyMPG = keyboard.nextDouble();