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

Write a program that reads in a line consisting of a student\'s name, social sec

ID: 3630359 • Letter: W

Question

Write a program that reads in a line consisting of a student's name, social security number, user id, and password. The program outputs the string in wgich all digits of the social security number, and all charecters in the password are replaced by x.(The social security number is in the form 000-00-0000, and the user id and the password do not contain any spaces.) Your program should not use the operator[ ] to access a string element.
I have tried the code from this question asked some time before, but it is the incorrect format and crashes. Please help.

Explanation / Answer

in response to your comment. rate this one, not the java

#include <iostream>
#include <string>
using namespace std;
int main()
{string name, ss,id,pass;
int n,m,i;
char c;
cout<<"Enter name, ss# user id and password all separated by a blank: ";
cin>>name;
cin>>id;
cin>>ss;
cin>>pass;
cout<<"name: "<<name<<endl;
cout<<"ID: "<<id<<endl;
n=ss.find("-");
ss=ss.replace(0,n,"XXX");
m=ss.find("-",n+1);
ss=ss.replace(n+1,m-(n+1),"XX");
ss=ss.replace(m+1,ss.length(),"XXXX");
cout<<"SS#: "<<ss<<endl;
for(i=0;i<pass.length();i++)
     pass=pass.replace(i,1,"X");
cout<<"Password: "<<pass<<endl;
system("pause");
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