SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 3 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 23 Nov 2017 My Price 8.00

prompt a user to enter a social security number

  • Your program should prompt a user to enter a social security number (SSN) as a series of digits.
  • It will check whether the user entered a valid 9-digit SSN and report an error message if the SSN entered is too short or too long or if the user enters a non-numeric input.
  • It should report a specific error message for each of the three possible errors listed in the bullet point above.
  • If the user makes a mistake, the program should re-prompt the user using a loop (suggestion: do-while loop).
  • Once the user enters a valid input, the program will display the SSN in the the format XXX-XX-XXXX
  • You are required to write a function with the following signature to check whether the user entered a numerical SSN (i.e. whether all of the digits entered were numerical). If the user enters any other character besides 0-9, return false, otherwise return true. Hint: Use ASCII
  • Copy and paste the below prototype above main and then write the function below main.

bool isNumeric(string SSN);

//use ASCII to determines if a string contains only the characters 0-9

  • You are also required to have a function with the following signature to display the SSN. 
  • Copy and paste the below prototype above main and then write the function below main.

void displayFormattedNumber(string SSN);

//Calls the formatSSN function and then displays it to the console

//With the message "You entered: " followed by the SSN

string formatSSN(string SSN);

//helper function to displayFormatted SSN

//converts a 9 character string into an SSN in the format XXX-XX-XXXX

 

  • Your program should work identically to example below:

Please enter a 9-digit SSN (no spaces no punctuation): 12345

You entered too few digits. Please try again.

 

Please enter a 9-digit SSN (no spaces no punctuation): 123456789012345

You entered too many digits. Please try again.

 

Please enter a 9-digit SSN (no spaces no punctuation): 123 456

You entered too few digits. Please try again.

 

Please enter a 9-digit SSN (no spaces no punctuation): 123 456 7890

Please enter a number with no spaces or punctuation. Please try again.

 

Please enter a 9-digit SSN (no spaces no punctuation): 123-45-6789

Please enter a number with no spaces or punctuation. Please try again.

 

Please enter a 9-digit SSN (no spaces no punctuation): 123456789

You entered: 123-45-6789

 

  • It is strongly suggested to structure your main function like this:

bool not_valid_SSN = true;

do {

    //user input

    if (test for too short) {

       //display appropriate error message

    } else if (!is_numeric(SSN)) {

       //display error message

    } else if(test for too long) {

       //display appropriate error message

    } else {

       //display appropriate formatted phone number

       not_valid_SSN = false;

    }

} while(not_valid_SSN);

Answers

(5)
Status NEW Posted 23 Nov 2017 12:11 PM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)