How Do You Write a Java Program to Accept a Character as Input and Do Something with It?

Problem scenario
You want to accept user input with a Java program. How do you write such a program?

Here is the program:

import java.util.Scanner;

public class acceptChar {

public static void main(String[] args) {
   System.out.println("Please enter a character, then press enter: ");
   Scanner in = new Scanner(;
   char letter =;

Leave a comment

Your email address will not be published. Required fields are marked *