// preprocessor directives
#include <iostream>
#include <string> // string class library
#include <iomanip> // setw(), fixed, showpoint, setprecision, left, right
using namespace std;
/* Function: main() *************************************************
*
* application entry point
* TODO: code main() according to pseodocode in directions handout
*/
// STUDENT CODE BEGINS
int main()
{
string enterPhoneNumber();
int isValid(string PhoneNumber);
string formatNumber(string PhoneNumber);
void displayResults(int status, string PhoneNumber);
void printHeading();
//-------------------------------------------------------------------
// General Functions
//-------------------------------------------------------------------
//
// input functions
//
/* Function: enterPhoneNumber() ************************************
* parameters: none
* return: phoneNumber : string
*
* Comments
* -prompt & get a telephone number
*
* TODO: code the enterPhoneNumber() function below this comment
*/
// assign a value to identifier
cout << "Enter Phone Number: ";
cin >> PhoneNumber;
// return value
return PhoneNumber;
}
// STUDENT CODE ENDS
//
// processing functions
//
/* Function: isValid() *******************************************
* parameters: phoneNumber : string
* return: status: int
* return a status of 0 if all is OK
* return a status of 1 if length is not 8 or 11
* return a status of 2 if first character not a 1
* return a status of 3 if number is not all digits 0-9
*
* TODO: code the isValid() function below this comment
*/
// STUDENT CODE BEGINS
// isValid() function
// NOTE about the integer value to be returned
// * return a status of 0 if all is OK
// * return a status of 1 if length is not 8 or 11
// * return a status of 2 if first character not a 1
// * return a status of 3 if number is not all digits 0-9
int isValid(string PhoneNumber)
{
int status;
if (PhoneNumber.length() != 8 && PhoneNumber.length() != 11)
status = 1;
else if (PhoneNumber.at(0) != '1')
status = 2;
else if (PhoneNumber.find_first_not_of("023456789", 0))
status = 3;
else // phone number is valid
status = 0;
return status;
}
// STUDENT CODE ENDS
/* Function: formatNumber() *****************************************
* parameters: phoneNumber : string (unformatted phone number)
* return: phoneNumber: string
* return an 8 digit phone number formatted like: 1-555-6789
* return an 11 digit phone number formatted like: 1-(234)-555-6789
*
* TODO: code the formatNumber() function below this comment
*/
/* Function: printHeading() **************************************
* return: void
*
* TODO: replace "<your name here>" with your name like
* "Joe Blough" <- remove < and > also!
*/
void printHeading();
{
/* declarations *************************************************/
// if any
// program title
cout << "Telephone Number Verification Program";
cout << endl << endl;
// program introduction and directions
cout << "\nWelcome to the Telephone Number Verification program. ";
cout << "\nWhen prompted, please enter either an 8 digit telephone number ";
cout << "\nor an 11 digit telephone number. Valid telephone numbers ";
cout << "\nwill always begin with 1, always have 8 digits or 11 digits, and ";
cout << "\ncontain only the digits 0-9." ;
What did you do wrong?
First of all you didn't use the source code format button (<>)
Second, you gave us heaps of code without telling us what errors you're getting or what the program even does.....
Also the people on this forum are not here to do your homework....