// File: inclass19.cpp
// Simulates the processing of a phone number by the telephone company.
//
// Input:  phoneNumber.
// Output: formattedNumber that shows areaCode, exchange and localNumber.
// -----------------------------------------------------------------------
// Class: CS 210                     Instructors: Drs. Hwang & Roberts
// Assignment: In-class exercise for 3/21/07 & 3/22/07
// Programmer(s): <fill in your name(s)>

#include <iostream>                // cin, cout, >>, <<, endl
#include <string>                  // string
using namespace std;

// Function prototypes

int main()
{
   string phoneNumber,       // Input phone number
          formattedNumber;   // Formatted phone number
   char response;            // User response to continue

   // Greet the user
   cout << "This program validates and formats local and "
        << "long distance phone numbers.\n";

   // Process phone numbers until the user wants to quit
   do
   {
      // Read in a phone number
      cout << "\nEnter a phone number (without punctuation or spaces): ";
      cin >> phoneNumber;

      // Check if number is valid
      if (IsValid(phoneNumber))
      {
         // Format and display the phone number
         formattedNumber = FormatPhoneNumber (phoneNumber);
         cout << formattedNumber << endl;
      }  // end if

      // Ask the user if they want to continue
      cout << "\nDo you want to process another phone number? (y/n) ";
      cin >> response;
   } while ((response == 'y') || (response == 'Y'));

   return 0;
}  // end main
