Java String Manipulation 28th Jan Practice 1 - to accept a character and check whether it is a letter or not. If letter, then convert it to uppercase or lowercase. Also check whether it is letter or a special character

Java Program to accept a character and check whether it is a letter or not. If letter, then convert it to uppercase or lowercase. Also check whether it is letter or a special character

Output

import java.util.*;


class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        char a;

        System.out.println("Enter a character");

        a = in.next().charAt(0);

        if(Character.isLetter(a)){

            System.out.println("Character "+ a+ " is letter");

            if(Character.isUpperCase(a)){

                System.out.println(Character.toLowerCase(a));

            }

            else

            System.out.println(Character.toUpperCase(a));

            

            

        }

        else if(Character.isDigit(a)){

            System.out.println(a+" is a digit");}

       

        else

        System.out.println(a+" is a special character");

        

        

            }

}

Comments

Translate

Popular posts from this blog

Letter to SBI Bank Manager of Local Branch to reduce the interest rate on home loan

Abhisara - the Tryst Notes

Summers are becoming hotter with each passing year. Write a description of one such very hot day. What did you see and hear as you walked outside? How were birds and animals affected?

Java Recursion Program Practise 5 - to input a number and print the sum of digits of the number

Macbeth Personal Notes: Act 1 Scene 3 (Part 2/2)

Java Recursion Program Practise 3 - Raising base to power of index

Java String Manipulation 28th Jan Practice 2 - input a string and check whether it is a palindrome or not

Java Recursion Program Practise 4 - to input a number and display sum from 1 to that number

Java Recursion Program Practise 2 - Fibonacci Series