java - 使用 java 扫描器
问题描述
如果这看起来很新鲜,我很抱歉,但我知道我们都得从哪里开始......它阻止我把用户数据放在甜点之后,远在它之前......这是一个编辑问题
包裹扫描仪;导入 java.util.Scanner;
公共类使用扫描仪{
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String userName;
int age;
String dessert;
System.out.println("Hi What is your name? ");
userName = sc.nextLine();
System.out.println ("How are you doing, " + userName + "?");
System.out.println ("What is you age, " + userName + "?");
age = sc.nextInt();
System.out.println ("Hello, " + userName + " you are " + age);
System.out.println ("ok, " + userName + " .Your are " + age + "." + " What is your favorite dessert?");
dessert = sc.nextLine();
System.out.println (" Hello, " + userName + "You are " + age + " and your favorite dessert is " + dessert);
}
}
解决方案
age 是一个整数,使用 age = sc.nextInt();
推荐阅读
- ios - 在图表 swift danielgindi 的库中禁用 X 轴的自动缩放
- dynamics-crm - 在具有多个工作流程的动态 CRM 上创建按钮
- jenkins - 从 Jenkins 管道中的“findFiles glob:”的输出中对文件名进行排序
- julia - Julia:将旋转应用于 ODE 解决方案
- python - Panda read_excel() 给出的日期值不正确
- docker - 无法在 docker 中使用 musl 目标 x86_64-unknown-linux-musl 编译 rust fasthash 库
- python-3.x - 使用函数式 API 的 Transformer 模型
- javascript - 如何就地调整three.js对象的大小(即保持在其位置)
- mysql - 创建一个表,其中一行的最后一列转移到下一列的第一行
- python - Python更新继承的字典