Email Address Creation: A company named Creative Engineering develops email addr
ID: 3762371 • 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
Last Name: Stephens Your email address is StephC321@creative.com
First Name: Clarence
EmployeeID: 7654321
Explanation / Answer
#include<iostream>
#include<string.h>
using namespace std;
int main() {
string lastName, firstName, employeeId;
cout<<"Last Name: ";
cin>>lastName;
cout<<"First Name: ";
cin>>firstName;
cout<<"EmployeeID: ";
cin>>employeeId;
char email[255];
int i=0;
for (int j=0; j<5; j++) {
email[i++]=lastName[j];
}
email[i++]=firstName[0];
for (int j=0; j<3; j++) {
email[i++]=employeeId[employeeId.length()-1-2+j];
}
email[i]='';
cout<<"Your email address is "<<strcat(email, "@creative.com");
cout<<" ";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.