Get New Ideas

I Need Program DO That :

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 which all digits of the social security number,and all the characters in the password are replaced by x(the social security number is in form 000-00-0000,and the user id and password do not contain any spaces.)Your program shouldn't use the operator [] to access a string element.

I Hope Get New Ideas From all :)
What is your idea/code?
i made it With the operator [] So i need another I dea
Last edited on
closed account (18hRX9L8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>

using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::getline;

int main(void)
{
	int counter;
	string name,ssn,userid,password;
	
	cout<<"Enter Name:  ";
	getline(cin,name);
	cout<<"Enter SSN:  ";
	getline(cin,ssn);
	cout<<"Enter User ID:  ";
	getline(cin,userid);
	cout<<"Enter password:  ";
	getline(cin,password);
	cout<<endl<<endl<<endl;
	cout<<"Name:  "<<name<<endl;
	cout<<"SSN:  xxx-xx-xxxx"<<endl;
	cout<<"User ID:  ";
	for(counter=0;counter<userid.length();counter++)
	{
		std::cout<<"x";
	}
	cout<<endl;
	cout<<"Password:  ";
	for(counter=0;counter<password.length();counter++)
	{
		cout<<"x";
	}
std::cin.ignore();
return(0);
}
Topic archived. No new replies allowed.