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();

}

}


No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner