/**s
* 〈一句话功能简述〉<br>
* 〈获取键盘〉
*
* @author abu
* @create 2019/7/4
* @since 1.0.0
*/
public class TestScanner {
public static void main(String[] args){
/*test1 从键盘获取值
Scanner s = new Scanner(System.in);
System.out .println("请随意敲击键盘");
String str = s.next();
System.out.println(str);
*/
/*testIf2 从键盘获取值之后给出不同结果
Scanner s = new Scanner(System.in);
System.out.println("你考了多少分呀?");
int score = s.nextInt();
if (score >=100 || score < 0){
System.out.println("are you sure what you import is right?");
}
else{
if (score == 100){
System.out.println("你可以获得BMW");
}
else if(score > 80 && score <= 90){
System.out.println("给你个iPhone5");
}
else if(score >= 60 && score <= 80){
System.out.println("给你一本书把~");
}
else{
System.out.println("you are so poor to get nothing!");
}
}
*/
/*testIf3 输入三个数字,自动从大到小排列
Scanner s = new Scanner(System.in);
System.out.println("please import the first number");
int num1 = s.nextInt();
System.out.println("please import the second number");
int num2 = s.nextInt();
System.out.println("please import the third number");
int num3 = s.nextInt();
System.out.println("the sort from the largest to the smallest is");
if(num1 > num2){
if(num3 > num1) {
System.out.println(num3 + "," + num1 + "," + num2 );
}else if(num3 < num2){
System.out.println(num1 +"," + num2 + "," + num3 );
}else{
System.out.println(num1 + "," + num3 +"," + num3 );
}
}
else{
if(num3<num1){
System.out.println(num2 +"," + num1 +"," + num3 );
}
else if(num3>num2){
System.out.println(num3 + "," + num2 +"," + num1 );
}
else{
System.out.println(num2 + "," + num3 + "," + num1 );
}
}
*/
//根据男生不同的条件判断是否嫁给他
/* Scanner s = new Scanner(System.in);
System.out.println("男生身高是多少呀?");
int height = s.nextInt();
System.out.println("男生有多少万财产呀?");
double assets = s.nextDouble();
System.out.println("男生帅吗?");
boolean looks = s.nextBoolean();
System.out.println("那你嫁不嫁啊?");
if (height > 180 & assets > 1000 & looks == true){
System.out.println("哦他是真命天子");
}
else if(height > 180 | assets > 1000 | looks == true)
System.out.println("还行,嫁吧...");
else{
System.out.println("你是好人!");
}
*/
}
}
练习1——Scanner
最新推荐文章于 2023-04-06 23:14:16 发布