C Write a program that asks a user to enter first name last

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

Solution

#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;

}

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 th
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 th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site