Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You work for the social security Administration and are asked to design a machin

ID: 3541255 • Letter: Y

Question

You work for the social security Administration and are asked to design a machine that generates, and prints new Social Security cards. When it is run, it must generate a random nine digit Social-Security number, separate the number into its individual digits, and then print the digits back separated from one another with dashes in appropriate positions. Printed output should look as the number normally appears on a Social-Security card. If the random number your program generated was, say, 123421390, you program should work like this:

Name SURNAME

123-42-1390

Every time your program runs, a new random number must come out.



Can anyone help me for this question. I have no idea about it...

Explanation / Answer

/* SAMPLE OUTPUT
Kumar Ravi
604-45-8567


#include<iostream>
#include<string>
#include<iomanip>
#include<stdlib.h>
#include <sstream>  
#include<time.h>
using namespace std;
int main()
{
srand(time(NULL));
string Name = "Kumar";
string sur_Name = "Ravi";
double Social_Security_number = rand()% 900000000 + 100000000;
std::stringstream ss;
ss <<setprecision(9) << (Social_Security_number);
string str= ss.str();
//cout << setprecision(9) << Social_Security_number << endl;
str.insert(3,1,'-');
str.insert(6,1,'-');
cout << Name << " " << sur_Name << endl;
cout << str << endl;

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote