Examples of java if

demand:
Student scores to determine a class distinction
>=90 A
90 <or> = 80 B
80 <or> = 70 C
70 <or> = 60 D
60< E
 
import javax.lang.model.util.ElementScanner6;

public class Iftext{
    public static void main(String[] args){
        double a=0;
        String answer = "invalid value, make sure that the value is accurate!";
        if(a>=90){
            answer="A";
            If //System.out.println("A");// is 90, the output is A;
        }
            else
            if(a<90 && a>=80){
                answer="B";
                //System.out.println("B");// equal to or greater than 90 is less than 80, then the output B;
            }
            else
            if(a<80 && a>=70){
                answer="C";
                //System.out.println("C");// is less than 80 or greater than or equal to 70, the output are C;
            }
            else
            if(a<70 && a>=60){
                answer="D";
                //System.out.println("D");// equal to or greater than 70 is less than 60, the output of D;
            }
            else
            if(a<60 && a>=0){
                answer="E";
                //System.out.println("E");// is less than 60 or greater than or equal to 0, then the output to E;
            }
            /*
            else
            {
                //System.out.println ( "invalid value, make sure that the value is accurate!");
            }
            */
            System.out.println(answer); 
        }
    }

Guess you like

Origin www.cnblogs.com/zhuojinyong/p/11605609.html