Java问题 为什么最后输入不了啊String CardName = input.nextLine(); 这里
importjava.util.Scanner;publicclassqwert{publicstaticvoidmain(String[]args){Scannerin...
import java.util.Scanner;
public class qwert {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please enter today's date.(Example:28) ");
int date=input.nextInt();
// simulate it by randomly generate numbers
int cardNumber = (int)(Math.random() * 52);
System.out.print("The card you picked is ");
if (cardNumber % 13 == 0)
System.out.print("Ace of ");
else if (cardNumber % 13 == 10)
System.out.print("Jack of ");
else if (cardNumber % 13 == 11)
System.out.print("Queen of ");
else if (cardNumber % 13 == 12)
System.out.print("King of ");
else
System.out.print((cardNumber % 13) + " of ");
if (cardNumber / 13 == 0)
System.out.println("Clubs");
else if (cardNumber / 13 == 1)
System.out.println("Diamonds");
else if (cardNumber / 13 == 2)
System.out.println("Hearts");
else if (cardNumber / 13 == 3)
System.out.println("Spades");
//enter the card you have picked
System.out.println("Please enter the card you had picked(you should copy and paste):");
String CardName = input.nextLine();
//hearts
}
} 展开
public class qwert {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please enter today's date.(Example:28) ");
int date=input.nextInt();
// simulate it by randomly generate numbers
int cardNumber = (int)(Math.random() * 52);
System.out.print("The card you picked is ");
if (cardNumber % 13 == 0)
System.out.print("Ace of ");
else if (cardNumber % 13 == 10)
System.out.print("Jack of ");
else if (cardNumber % 13 == 11)
System.out.print("Queen of ");
else if (cardNumber % 13 == 12)
System.out.print("King of ");
else
System.out.print((cardNumber % 13) + " of ");
if (cardNumber / 13 == 0)
System.out.println("Clubs");
else if (cardNumber / 13 == 1)
System.out.println("Diamonds");
else if (cardNumber / 13 == 2)
System.out.println("Hearts");
else if (cardNumber / 13 == 3)
System.out.println("Spades");
//enter the card you have picked
System.out.println("Please enter the card you had picked(you should copy and paste):");
String CardName = input.nextLine();
//hearts
}
} 展开
展开全部
input.nextLine 是读标准输入,println是输出标准输出。
结果冲突了。
你在hearts部分再读一次就对了
结果冲突了。
你在hearts部分再读一次就对了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
麻烦说清楚一点你的问题,你试试改成这 String CardName = input.next();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把错误爆出来啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询