In: Computer Science
You will ask the end user to type their first name and their
last name and store it on separate
string variables, you will ask for the gender, you will then
concatenate both strings into a third
string variable. You will salute the end user as Mr. or Ms
depending on the gender and last you
will display the initials of the end user. (You must use methods of
the string class in this lab)
Code
#include<iostream>
#include<string>
using namespace std;
int main()
{
string firstName,lastName,gender,fullName;
cout<<"Enter your First name: ";
cin>>firstName;
cout<<"Enter your Last name: ";
cin>>lastName;
cout<<"Enter your gender ('M/F'): ";
cin>>gender;
if(gender=="M")
fullName="Mr. "+firstName+"
"+lastName;
if(gender=="F")
fullName="Ms. "+firstName+"
"+lastName;
cout<<"\nFull name:
"<<fullName<<endl<<endl;
return 1;
}
outputs
If you have any query regarding the code
please ask me in the comment i am here for help you. Please do not
direct thumbs down just ask if you have any query. And if you like
my work then please appreciates with up vote. Thank You.