Showing posts with label Programs On Character. Show all posts
Showing posts with label Programs On Character. Show all posts

Sunday, July 19, 2020

Java Program On ASCII Code And Equivalent Character


Input an ASCII code, reverse the ASCII code and display the equivalent character

e.g: Entered value: 98

Reverse: 89

Output: Y

 

import java.util.*;

class Char5

{

 Int n, rev=0;

Scanner sc=new Scanner(System.in);

void take()

{

System.out.print(“\nEnter the ASCII Code:”);

n=sc.nextInt();

if(n%10==0)

{

 System.out.print(“\n Reversing not possible.”);

System.exit(0);

}

while(n>0)

{

 rev=rev*10+n%10;

n=n/10;

}

System.out.print((char)rev);

}

public static void main(String args[])

{

Char5 ob=new Char5 ();

ob.take ();

}

}

Friday, July 17, 2020

Java Program On Displaying Character Corresponding To Number


Write a program to input a number N (0<N<27). Display the letter corresponding to the number (if N is 1, display A)

 

import java.util.*;

class Char4

{

 char ch;

int N;

void take()

{

for(;; )

{

System.out.print(“\nEnter the number (1-26):”);

N=sc.nextInt();

If(N>0 && N<27)

break;

}

System.out.print((char)(N+64));

}

public static void main(String args[])

{

Char4 ob=new Char4();

ob.take ();

}

 

}


Tuesday, July 14, 2020

Java Program To Display All Alternate Characters From A to Z


class Char3

{

 char ch;

int i;

void take()

{

 for(i=65;i<=90;i=i+2)

{

ch=(char)(i);

System.out.print(“ “+ch);

}

public static void main(String args[])

{

Char3 ob=new Char3();

ob.take ();

}

}


Monday, July 13, 2020

Enter a character and display the next 5 characters Using Java


import java.util.*;

class Char2

{

 char ch;

int i;

Scanner sc=new Scanner(System.in);

void take()

{

 System.out.print(“\nEnter any character:”);

ch=sc.next().charAt(0);//A

ch=(char)(ch+1);//B

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

{

System.out.print(“ “+ch);//B C

ch=(char)(ch+1);

}

public static void main(String args[])

{

Char2 ob=new Char2();

ob.take ();

}

 }


Sunday, July 12, 2020

Java Program on Displaying 10th Character from Entered Character


Enter a character and display the next 10th character in ASCII table

import java.util.*;

class Char1

{

 char ch;

int i;

Scanner sc=new Scanner(System.in);

void take()

{

 System.out.print(“\nEnter any character:”);

ch=sc.next().charAt(0);

i=ch+10;

if(i>90 )

i=65+(i-90);

else if(i>122 )

i=97+(i-122);

ch=(char)i;

System.out.println(“\n10th character=”+ch);

}

public static void main(String args[])

{

Char1 ob=new Char1();

ob.show();

}

}


Subscribe via email

Enter your email address:

Delivered by FeedBurner