Monday, June 4, 2007

Q5: Mark Rank

Q: Ranking a mark:
1. Greater than or equal to 90, it is A;
2. Between 60 and 89, it is B;
3. Less than 60, it is C.


A:

public class MarkRank {
public static char rankMark(int mark){
if(mark >= 90) return 'A';
else if((mark <=89) && (mark >=60)) return 'B';
else return 'C';
}

public static void main(String[] args) {
System.out.println("Mark 95: " + MarkRank.rankMark(95));
System.out.println("Mark 78: " + MarkRank.rankMark(78));
System.out.println("Mark 59: " + MarkRank.rankMark(59));
}
}

No comments: