write a program in java to input a character display next 5 characters
Answers
Answer:
Hi,
it is a program that used to input a character and it also outputs that character
[code java]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a character: ");
char c = scanner.next().charAt(0);
System.out.println("You have entered: "+c);
}
}
[/code]
you can use a Scanner to read from input (for a single character):
[code java]
Scanner scanner = new Scanner(System.in);
char c = scaner.next().charAt(0);
[/code]
You can either scan an entire line:
[code java]
Scanner s = new Scanner(System.in);
String str = s.nextLine();
[/code]
Thank you.
Answer:
public class no.
{
public static void main(ch a,b,c,d,e)
{
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);
}
}