java 判断语句

import java.util.Scanner;
public class Example_32 {

	public static void main(String[] args) {
		// 条件分支
		int a = 9,b = 5,c = 7,t = 0;
		if(b<a){
			t = a;
			a = b;
			b = t;
		}
		if(c<a){
			t = a;
			a = c;
			c = t;
		}
		if(c<b){
			t = b;
			b = c;
			c = t;
		}
		System.out.println("a="+a+",b="+b+",c="+c);
		System.out.println("--------");
		int math = 65, english = 85;
		if(math>60){
			System.out.println("数学及格了");
		}
		else{
			System.out.println("数学不及格");
		}
		if(english>90){
			System.out.println("英语是优");
		}
		else{
			System.out.println("英语不是优");
		}
		System.out.println("我现在学习if-else语句");
		System.out.println("--------");
		//switch语句
		int number = 0;
		System.out.println("输入正整数(回车确定)");
		Scanner reader = new Scanner(System.in);
		number = reader.nextInt();
		switch(number){
		case 9 :
		case 131 :
		case 12 : System.out.println(number+"是三等奖");
				  break;
		case 209 :
		case 596 :
		case 27 : System.out.println(number+"是二等奖");
		case 875:
		case 316:
		case 59: System.out.println(number+"是一等奖");
				 break;
		default: System.out.println(number+"未中奖");
		System.out.println("--------");
		//for循环
		long sum = 0,q = 8,item = q,n = 12,i = 1;
		for(i=1;i<n;i++){
			sum = sum+i;
			item = item*10+q;
		}
		System.out.println(sum);
		}
	}

}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值