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

}

 }


No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner