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

Please help with this code in C++ 4.12 CH4 LAB: Name format Many documents use a

ID: 3715381 • Letter: P

Question

Please help with this code in C++

4.12 CH4 LAB: Name format Many documents use a specific format for a person's name. Write a program whose input is: firstName middleName lastName, and whose output is: lastName, firstName middlelnitial. If the input is Pat Silly Doe, the output is: Doe, Pat S. If the input has the form firstName lastName, the output is lastName, firstName. If the input is: Julia Clark, the output is Clark, Julia Note: This lab focuses on strings, using a loop is not necessary. LAB ACTIVTY 4.12.1: CH4 LAB: Name format 0/10 main.cpp Load default template... 1 #include #include 3 using namespace std; 5 int mainO 7Type your code here. 9 return 0; 10

Explanation / Answer

#include <iostream>
using namespace std;


int main() {
string firstName, middleName, lastName;
cin >> firstName>> middleName>> lastName;
cout<<lastName<<", "<<firstName<<" "<<middleName[0]<<"."<<endl;
return 0;
}

Output:

Doe, Pat S.