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

C++ Write a program that asks a user to enter first name, last name, and a year,

ID: 3935348 • Letter: C

Question

C++

Write a program that asks a user to enter first name, last name, and a year, it will

construct an account ID in the format of:

firstname.lastnameYY

where the field “firstname” is user’s first name allowing no more than (first) five letters; the field “lastname” is user’s last name allowing no more than (first) six letters; and the filed “YY” is the lower two digits of the year. For example:

first name entered: Michael

last name entered: Richmond

year entered: 1985

the constructed account ID will be:

Micha.Richmo85

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

string fname,lname;

string year;

cout<<"enter firstname :";

cin>>fname;

cout<<" enter last name :";

cin>>lanme;

cout<<" year entered : ";

cin>>year;

string accid;

if(fname.length>5)

accid=accid+fname.substr(0,5)+".";

else

accid=accid+fname;

if(lname.length>5)

accid=accid+lname.substr(0,5);

else

accid=accid+lname;

accid=accid+year.substr(2,2);

cout<<" the constructed account ID wil be :"<<accid;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote