程序什么都没有

时间:2014-10-18 16:56:27

标签: java

public class evenVSodd 
{
    public static void main(String[] args)
    {
        int a; 
        a = 4;

        if (a/2==0)
        {
            System.out.print("its an even number");
        }
        else 
        {
            System.out.print("its a odd number");
        }
    }
}

结果是:

 ----jGRASP exec: java evenVSodd

its a odd number
 ----jGRASP: operation complete.

1 个答案:

答案 0 :(得分:1)

以下是代码:

import java.util.Scanner;

    public class EvenAndOdd {
        public static void main(String[] args) {
            int a;
            Scanner sc=new Scanner(System.in);    
            System.out.println("Enter the Number :");
            a = sc.nextInt();
            if(a%2==0) {
               System.out.print("its an even number");
            }
            else {
               System.out.print("its a odd number");
          }
       }
    }

运行它,您将获得输出。

注意:运行代码后,请阅读上面的评论作为他们要说的内容并尝试遵循。这只会改善你的