English

Write a program in Java to input a character. Display next 5 characters. - Computer Applications

Advertisements
Advertisements

Question

Write a program in Java to input a character. Display next 5 characters. 

Answer in Brief

Solution

import java.util.*;
public class Q2
{
public static void main(String args[])
{Scanner in = new Scanner(System.in);
char ch;
System.out.println("Enter a character");
ch = in.next().charAt(0);
for (int i = ch + 1; i <= ch + 5; i++)
System.out.println((char) i);
}}
shaalaa.com
  Is there an error in this question or solution?
Chapter 2: Library Classes - EXERCISES [Page 179]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 2 Library Classes
EXERCISES | Q VIII. 2. | Page 179
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×