[Java basic] การใช้ if else if
ตัวอย่าง การใช้งาน if else if
/** * * @author http://javaagkasit.blogspot.com/ */ public class ifelseif { public static void main(String [] args){ int score = 60; if(score <= 49){ System.out.println("gate F"); }else if (score <= 59 ){ System.out.println("gate D"); }else if(score <= 69){ System.out.println("gate C"); }else if(score <= 79){ System.out.println("gate B"); }else if(score <= 100){ System.out.println("gate A"); }else{ System.out.println("enter score"); } } } |
output