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

A Guide to SQL
9th Edition
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Philip J. Pratt
Chapter8: Sql Functions And Procedures
Section: Chapter Questions
Problem 3SCG
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning