Answer:
In C++:
#include <iostream>
using namespace std;
int main(){
string fname,lname; int num;
cout<<"Firstname: "; cin>>fname;
cout<<"Lastname: "; cin>>lname;
cout<<"4 digits: "; cin>>num;
string login = lname;
if(lname.length()>=5){
login = lname.substr(0, 5); }
login+=fname.substr(0,1)+to_string(num%100);
cout<<login;
return 0;
}
Step-by-step explanation:
This declares the first name, last name as strings and 4 digit number as integer
string fname,lname; int num;
This prompts and get input for last name
cout<<"Firstname: "; cin>>fname;
This prompts and get input for first name
cout<<"Lastname: "; cin>>lname;
This prompts and get input for four digit number
cout<<"4 digits: "; cin>>num;
This initializes login information to last name
string login = lname;
This checks if length of login is 5 and above
if(lname.length()>=5){
If yes, it gets the first five letters only
login = lname.substr(0, 5); }
This adds the first character of first name and the last 2 digits of num to login
login+=fname.substr(0,1)+to_string(num%100);
This prints the login information
cout<<login;