Back to Examples
package edu.iuk.EnglishNumbers;

import java.util.Scanner;

public class EnglishNumbers {

  public static void main(String[] args) {

    //Jacob Morris

    //declare variables
    String number;
    int numLength;
    int counter = 0;

    //retrieve numbers from the user
    Scanner numbers = new Scanner(System.in);
    System.out.println(“Please enter a number: “);
    number = numbers.nextLine();

    numLength = number.length();

    while(counter < numLength) {

      if(number.substring(counter, counter+1).equals(“0”)){

        System.out.println(“Zero”);

      } else if(number.substring(counter, counter+1).equals(“1”)){

        System.out.println(“One”);

      } else if(number.substring(counter, counter+1).equals(“2”)){

        System.out.println(“Two”);

      } else if(number.substring(counter, counter+1).equals(“3”)){

        System.out.println(“Three”);

      } else if(number.substring(counter, counter+1).equals(“4”)){

        System.out.println(“Four”);

      } else if(number.substring(counter, counter+1).equals(“5”)){

        System.out.println(“Five”);

      } else if(number.substring(counter, counter+1).equals(“6”)){

        System.out.println(“Six”);

      } else if(number.substring(counter, counter+1).equals(“7”)){

        System.out.println(“Seven”);

      } else if(number.substring(counter, counter+1).equals(“8”)){

        System.out.println(“Eight”);

      } else if(number.substring(counter, counter+1).equals(“9”)){

        System.out.println(“Nine”);

      }

      counter ++;

    }

  }

}
Back to Examples

Startup Discount
Small Business?
Contact us for an Enormous Discount!