Computer Science, asked by karthikeya60605, 1 month ago

create a program to display whether the entered character is in uppercase or lowercase in java​

Answers

Answered by ananth32
0

Answer:

easy version 1:

//program to check whether the entered character or letter is in upc or in lwc

class ULcase1

{

public void main (char ch) //ch inputs data from the user

{

if(ch=='A' || ch=='B' || ch=='C' || ch=='D' || ch=='E' || ch=='F' || ch=='G' | | ch=='H' || ch=='I' || ch=='J' || ch=='k' || ch=='L' || ch=='M' || ch=='N' || ch=='O' ||

ch=='P' || ch=='Q' || ch=='R' || ch=='S' || ch=='T' ||

ch=='U' || ch=='V' || ch=='W' || ch=='X' || ch=='Y' ||ch=='Z')

System.out.println(+ch+"is an Uppercase Character");

else if(ch=='a' || ch=='b' || ch=='c' || ch=='d' || ch=='e' || ch=='f' || ch=='g' | | ch=='h' || ch=='i' || ch=='j' || ch=='k' || ch=='l' || ch=='m' || ch=='n' || ch=='o' ||

ch=='p' || ch=='q' || ch=='r' || ch=='s' || ch=='t' ||

ch=='u' || ch=='v' || ch=='w' || ch=='x' || ch=='y' ||ch=='z')

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

else

System.out.println(+Ch+"is not a Character!!!!!!");

}

}

easy version 2:

//program to check how many upc or lwc present in a given sentence or string

class ULcase2

{

public void main (String ch, int b) //ch inputs data from the user b inputs choice

{

int i,upc,lwc;

int a = ch.length( ); //stores the length of the given character (letter) or string (sentence)

for(i=0;i<=a;i++)

{

if(Character.isUppercase(ch))

upc++;

else if (Character.isLowercase(ch))

lwc++;

}

// you can even give choice for printing the statements eh: type 1 to print no of upc present, type 2 to print no of lwc present, type 3 to print both

if(b==1)

System.out.println("Number of Upper case characters present:"+upc);

else if(b==2)

System.out.println("Number of Lower case characters present:"+lwc);

else

System.out.println("Number of Upper case characters present:"+upc);

System.out.println("Number of Lower case characters present:"+lwc);

}

}

Similar questions