Email Address Creation: A company named Creative Engineering develops email addr
ID: 3763426 • Letter: E
Question
Email Address Creation: A company named Creative Engineering develops email addresses for their employees by using the first 5 digits of their last name (or all digits if less than 5), the first digit of their first name, and the last 3 digits of their EmployeeID, followed by “@creative.com”. Write a c++ program that will prompt the user to enter his/her last name, first name, and their EmployeeID. The program should then display their email address.
Input Output Output
Last Name: Stephens Your email address is StephC321@creative.com
First Name: Clarence
EmployeeID: 7654321
Input Output
Last Name: Doe Your email address is DoeJ030@creative.com
First Name: John
EmployeeID: 1020030
Explanation / Answer
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
string lname,fname,empid,email_address="";
cout<<"Last Name: ";
cin>>lname;
cout<<"First Name: ";
cin>>fname;
cout<<"EmployeeID: ";
cin>>empid;
int i;
if (lname.length()<=5) {
email_address=email_address+lname;
}
else{
email_address=lname.substr(0,5);
}
email_address=email_address+fname.substr(0,1)+empid.substr(empid.length()-3,3)+"@creative.com";
cout<<"Your email address is "<<email_address<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.