Answer to Question #274862 in C++ for jjl

Question #274862

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 the digits of the Social Security number and all the characters 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.


1
Expert's answer
2021-12-02T18:10:19-0500
#include <iostream>
#include <string>
using namespace std;
int main(){
    string ssn, password, name;
    int id;
    cout<<"Enter name: ";
    cin>>name;
    cout<<"Enter social security number: ";
    cin>>ssn;
    cout<<"Enter user ID: ";
    cin>>id;
    cout<<"Enter password: ";
    cin>>password;


    cout<<"\nSSN: xxx-xx-xxxx\n";
    cout<<"Password: ";
    for(int i = 0; i < password.length(); i++){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment