題目

判斷數值使否大於等於0

package ch5;
import java.io.*;
public class ch5_7_1 
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader in=new InputStreamReader(System.in);
        BufferedReader buf=new BufferedReader(in);
        int a;
        String sa;
        sa=buf.readLine();
        a=Integer.parseInt(sa);
        if (a>=0)
            if (a==0)
                System.out.print(a+"等於0");
            else
                System.out.print(a+"大於0");
        else
            System.out.print(a+"小於0");
    }

}
輸出結果

-1
-1小於0

創作者介紹
創作者 驢子的生活日記 的頭像
驢子

驢子的生活日記

驢子 發表在 痞客邦 留言(0) 人氣( 13 )