Question: C++ Programming: In this exercise, you modify the Social Security Number program from the chapter. If necessary, create a new project named Intermediate24 Project and
C++ Programming:
In this exercise, you modify the Social Security Number program from the chapter. If necessary, create a new project named Intermediate24 Project and save it in the Cpp8\Chap13 folder. Enter the instructions from Figure 13-22 into a source file named Intermediate24.cpp. Change the filename in the first comment. Before inserting the missing hyphens, verify that the nine characters entered by the user are numeric. Save and then run the test program.
Reference Problem: //SSN.cpp-displays the Social Security number with hyphens
//Created/revised by
#include
#include
using namespace std;
int main()
{
string ssn = "";
cout<<"Nine-character Social Security number: ";
getline(cin, ssn);
if (ssn.length()==9)
{
//insert hyphens
ssn.insert(3,"-"); //xxx-xxxxxx
ssn.insert(6,"-"); //xxx-xx-xxxx
cout<<"Social Security number: "< } else cout<<"The number must contain 9 characters"< //end if system("pause"); return 0; }//end of main function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
