c++ code Also in code i am getting "sh: 1: PAUSE: not found" 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. Use the appropriate functions described in Table 7-1 below. #include //include statement(s) #include #include using namespace std; //using namespace statement(s) void getInfo(string info); //void function header to get info int main() { string k; //variable declaration(s) cout << "Enter your Name, Social Security number, User ID, and Passord - separated\nby commas: " << endl; cout << endl; getline(cin, k); //reads the values the user inputs cout << endl; getInfo(k); //void function call to get info cout << endl; system ("PAUSE"); //black box appears return 0; //return statement(s) } void getInfo(string info) { int pos1 = info.find(",", 0); //finds the position(s) after each comma int pos2 = info.find(",", pos1 + 1); int pos3 = info.find(",", pos2 + 1); int lastPos = info.length() - 1; //finds the last position int nameLength = pos1 - 0; //finds the length for each position(s) int ssnLength = pos2 - (pos1 + 1); int idLength = pos3 - (pos2 + 1); int passLength = lastPos - (pos3 + 1) + 1; string passwordMask = info.substr(pos3 + 1, passLength); //passwordMask is a substring to convert the for (int i = 0; i < passLength; i++) //password characters into X's { passwordMask.erase(i, 1); passwordMask.insert(i, "X"); } string ssnMask = info.substr(pos1 + 1, ssnLength); //ssnMask is a substring to convert the social security for (int i = 0; i < ssnLength; i++) //numbers into X's, added condition if there are '-' { //to NOT make them X's if (ssnMask.at(i) != '-') { ssnMask.erase(i, 1); ssnMask.insert(i, "X"); } } cout << "Your name is: " << info.substr(0, nameLength) << endl; cout << "Social Security Number is: " << ssnMask << endl; cout << "Your ID is: " << info.substr(pos2 + 1, idLength) << endl; cout << "Your password is: " << passwordMask << endl; return; } CODE WORKS FINE, BUT THE OUTPUT NEEDS TO BE ONLY IN ONE LINE! Not as pictured in the attachment. Below is how the output should read, it does need to be like the attachment, just one line with the output below.  John Doe xxxxxxxxx DoeJ xxxxxxxxxxx

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

c++ code

Also in code i am getting "sh: 1: PAUSE: not found"

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. Use the appropriate functions described in Table 7-1 below.

#include <iostream> //include statement(s)
#include <iomanip>
#include <string>

using namespace std; //using namespace statement(s)

void getInfo(string info); //void function header to get info

int main()
{
string k; //variable declaration(s)
cout << "Enter your Name, Social Security number, User ID, and Passord - separated\nby commas: " << endl;
cout << endl;

getline(cin, k); //reads the values the user inputs
cout << endl;

getInfo(k); //void function call to get info
cout << endl;

system ("PAUSE"); //black box appears
return 0; //return statement(s)
}

void getInfo(string info)
{
int pos1 = info.find(",", 0); //finds the position(s) after each comma
int pos2 = info.find(",", pos1 + 1);
int pos3 = info.find(",", pos2 + 1);
int lastPos = info.length() - 1; //finds the last position

int nameLength = pos1 - 0; //finds the length for each position(s)
int ssnLength = pos2 - (pos1 + 1);
int idLength = pos3 - (pos2 + 1);
int passLength = lastPos - (pos3 + 1) + 1;

string passwordMask = info.substr(pos3 + 1, passLength); //passwordMask is a substring to convert the
for (int i = 0; i < passLength; i++) //password characters into X's
{
passwordMask.erase(i, 1);
passwordMask.insert(i, "X");

}

string ssnMask = info.substr(pos1 + 1, ssnLength); //ssnMask is a substring to convert the social security
for (int i = 0; i < ssnLength; i++) //numbers into X's, added condition if there are '-'
{ //to NOT make them X's

if (ssnMask.at(i) != '-')
{
ssnMask.erase(i, 1);
ssnMask.insert(i, "X");
}
}

cout << "Your name is: " << info.substr(0, nameLength) << endl;
cout << "Social Security Number is: " << ssnMask << endl;
cout << "Your ID is: " << info.substr(pos2 + 1, idLength) << endl;
cout << "Your password is: " << passwordMask << endl;

return;
}

CODE WORKS FINE, BUT THE OUTPUT NEEDS TO BE ONLY IN ONE LINE!

Not as pictured in the attachment.

Below is how the output should read, it does need to be like the attachment, just one line with the output below. 

John Doe xxxxxxxxx DoeJ xxxxxxxxxxx

Results
John Doe xхххххххх Doе] ххххххXхх
Expected Output ©
John Doe XXXXXXXXX DoeJ XXXXXXXXXXX
Run Checks
Submit 0%
Transcribed Image Text:Results John Doe xхххххххх Doе] ххххххXхх Expected Output © John Doe XXXXXXXXX DoeJ XXXXXXXXXXX Run Checks Submit 0%
Enter your Name, Social Security number,
User ID, and Passord - separated
by commas:
John Doe, 333224444, DoeJ, 123Password
Your name is: John Doe
Social Security Number is: XXXXXXXXXX
Your ID is: DoeJ
Your password is: XXXXXXXXXXXX
t sh: 1: PAUSE: not found
Transcribed Image Text:Enter your Name, Social Security number, User ID, and Passord - separated by commas: John Doe, 333224444, DoeJ, 123Password Your name is: John Doe Social Security Number is: XXXXXXXXXX Your ID is: DoeJ Your password is: XXXXXXXXXXXX t sh: 1: PAUSE: not found
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education