DEV Community

pranavinu
pranavinu

Posted on

Decision making Statement task

1.Write a program to check whether a given number is even
or odd.
if(a%2==0)
{
System.out.println(" even ");
}

    else
    {
        System.out.println("odd");
    }
Enter fullscreen mode Exit fullscreen mode

output: even

2)2.Write a program to check whether a given character is an alphabet, digit, or special character

    char b ='A';
    {
        switch (b)

        case 'A':
            System.out.println("alphebet");
            break;
        case '2':
            System.out.println("digits");
            break;
        case '&':
            System.out.println("special char");
            break;
            default:
                System.out.println("decimal values");
    }   
Enter fullscreen mode Exit fullscreen mode

output:alphebet

3.Write a program to check whether a given character is a vowel or consonant
char c ='e';
{
switch (c)

            case 'a','e','i','o','u':
                System.out.println("vowels");
                break;
            default:
                System.out.println("consonent");

            }
Enter fullscreen mode Exit fullscreen mode

output:vowels

Top comments (0)