JAVA basic programming exercises [5] program 5 judges scores level

 

[5] program 5 judges scores level

Title: using nested conditional operator to complete this question: academic> = 90 points represented by students A, B is represented by between 60-89 minutes is represented by C 60 points or less.

Analysis procedures: (a> b) a:? B which is an example of the basic conditions for the operators.

 

package cskaoyan;

public class cskaoyan5 {

	@org.junit.Test
	public void judge() {
		java.util.Scanner in = new java.util.Scanner(System.in);
		int score = in.nextInt();
		System.out.println(grade(score));
		in.close();
	}

	public char grade(int score) {
		return (score >= 90) ? 'A' : ((score >= 60) ? 'B' : 'C');
	}
}

 

Guess you like

Origin www.cnblogs.com/denggelin/p/11286337.html