Scanner控制台输入

//import java.util.Scanner;
import java.util.*;

//import com.sun.corba.se.spi.orbutil.fsm.Input;


public class Game {
	public static void main(String[]args){
		String a[]={"快乐","高兴","悲伤"};
		Scanner sc2=new Scanner(System.in);
		for(int i=0;i<=a.length;i++){
			
			int s=sc2.nextInt();//接收输入
			if (s==1){
				System.out.println(a[0]);
			}
			else if (s==2){
				System.out.println(a[1]);
			}
			else if (s==3){
				System.out.println(a[2]);
			}
			else {
				System.out.println("超标了");
				
			}
		}
		
		
		System.out.println("*******************");
		Scanner sc=new Scanner(System.in);
		String m="-1";
		while(!"t".equalsIgnoreCase(m)){//循环输入
			System.out.println("请输入学生成绩:");
			int xx=sc.nextInt();//接受输入
			if (xx>90){
				System.out.println("优秀");
				//sc.next();
			}
			
			else if (xx>70){
				System.out.println("良好");
				//sc.next();
			}
			else if (xx>60){
				System.out.println("及格");
				//sc.next();
			}
			else if (xx<60){
				System.out.println("不及格");
				//sc.next();
			}
			else {
				System.out.println("不要乱输入啦!");
				//sc.next();
			}
		}
		/*
		Scanner s = new Scanner(System.in);
		  String m="-1";
		  while(!"t".equalsIgnoreCase(m)){
		   System.out.println("请输入学生成绩:");
		   m = s.next();
		   if("t".equalsIgnoreCase(m)){
		    System.out.println("感谢使用");
		    break;
		   }else{
		    int n = Integer.parseInt(m);
		    String str = (n>=90)?"A":(n>=60)?"B":"C";
		    System.out.println(str); 
		   }
		  }*/
	}
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值