Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Must be done in Java. Write a program that reads a char as an input from the key

ID: 3799769 • Letter: M

Question

Must be done in Java.

Write a program that reads a char as an input from the keyboard and outputs whether it is a digit. (Hint: look for a method in the Character class.)

here is the sample output:

Complete #43 on page 273. Use if and else if statements for this program. Example output is e Problems Javadoc Declaration O Console 23 DigitCheck Uava cation] C:Program FilesJava el 8.0.111 bin Jan 3, 2017, 12:15:05 PM) aW.exe Enter a character 1 is a digit or if a letter is entered Problems a Javadoc Declaration O Console 23 kterminated DigitCheck Java ication] C:NPI ram FilesUavalirel .exe (Jan 3, 2017, 12:15:40 PM) Enter a character a is not a digit

Explanation / Answer

public class Character
{
    public static void main(String args[])
    {
        char ch;
        Scanner charac = new Scanner(System.in);
  
        System.out.print("Enter a character : ");
        ch = charac.next().charAt(0);
  
        if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z'))
        {
            System.out.print(ch + " is not a digit");
        }
        else
        {
            System.out.print(ch + " is a digit");
        }
    }
}