/*********************************************
Write out zip code

Write a program that reads in a zip code and
writes it out as words.  A typical run of the
program might look like:

  Enter zip code: 21218
  two one two one eight 

*********************************************/
#include <iostream>
#include <string>
using namespace std;

string digitname(char);

/*********************************************
 ** main() function
 *********************************************/
int main()
{
  /******************************************
     Read in each of the 5 digits of the zip
     code as a character, and write it out as
     the full string
  *******************************************/
  cout << "Enter zip code: ";
  for(int i = 0; i < 5; i++)
  {  
    char c;
    cin >> c;
    cout << digitname(c) << ' ';
  }
  cout << endl;

  return 0;
}

/*********************************************
 ** digitname - takes a char argument storing
 ** a digit, and returns the digit as a string.
 ** ex digitname('2') returns "two".
 *********************************************/
string digitname(char c)
{
  if (c == '0')
    return "zero";
  else if (c == '1')
    return "one";
  else if (c == '2')
    return "two";
  else if (c == '3')
    return "three";
  else if (c == '4')
    return "four";
  else if (c == '5')
    return "five";
  else if (c == '6')
    return "six";
  else if (c == '7')
    return "seven";
  else if (c == '8')
    return "eight";
  else if (c == '9')
    return "nine";
  else
    return "error";
}