If条件判断_Java基础入门阶段(零基础java入门教程)_学习笔记

本文学习内容来自腾讯课堂提供的学习视频。进入腾讯课堂官网,搜索  Java基础入门阶段 就可以看到这门免费培训视频。

培训视频详细类别为:IT 互联网> 编程语言>Java>Java基础入门阶段(javase教程,零基础java入门教程)(阶段一)。

本文是对该培训视频的学习笔记。仅供参考。

class Demoif1{
	
	public static void main(String[] args){
	
	int score = 57;
	
	  if(score >= 60){
		
		System.out.println("gongxi ni jige le ");
	  }else{
		System.out.println("ni mei jige le ");
		  
	  }
	  System.out.println("program end");
	}
}

运行结果:

ni mei jige le
program end

 

示例:打印每个员工的工资等级,如果大于3000就是D级,如果大于5000是C级,如果大于8000是B级,如果大于10000是A级。

class Demoif3{
	
	public static void main(String[] args){
	
	int sal = 20000;
	if(sal > 3000 && sal <= 5000){
	  System.out.println("D");
	}
	if(sal > 5000 && sal <= 8000){
	  System.out.println("C");
	}
	if(sal > 8000 && sal <= 10000){
	  System.out.println("B");	
	}
	if(sal > 10000){
	  System.out.println("A");
	}
	System.out.println("program end");
  }
}

运行结果:

A
program end

class Demoif4{
	
	public static void main(String[] args){
	
	int sal = 9000;
	if(sal > 10000){
	  System.out.println("A");
	  	
	}else if (sal > 8000){
	  System.out.println("B");	
	
	}else if (sal > 5000){
	  System.out.println("C");	
		
	}else if (sal > 3000){
	  System.out.println("D");
		
	}else{
	  System.out.println("wuji");
		
	}	
	System.out.println("program end");
  }
}

运行结果:

B
program end

 

 

你可能感兴趣的:(java入门学习)