Number to Words in Java: Explanation & Practice

Convert a single digit to its English word

Problem summary

Write a program that converts a single digit (0-9) to its English word representation.

Starter code

public class Main {
    public static void main(String[] args) {
        int digit = 7; // Test case 1
        
        // Convert digit to word
        // Print the word: Seven
    }
}

Expected output and test cases

  • 7 → Seven
    Seven
  • 0 → Zero
    Zero
  • 3 → Three
    Three

Hints

  1. Use switch statement or array of words
  2. Handle each digit 0-9
  3. String[] words = {"Zero", "One", ...}

Related Core Java Basics exercises

Practice all Core Java Basics exercises · Run this idea in the Java compiler