1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <iostream>
#include <cstring>
using namespace std;
void input(char first_name, char middle_name, char last_name);
void output(char first_name, char middle_name, char last_name);
void change(char middle_name, char last_name);
int main()
{
char first_name;
char middle_name;
char last_name;
input(first_name, middle_name, last_name);
change(middle_name, last_name);
output(first_name, middle_name, last_name);
}
void input(char first_name, char middle_name, char last_name)
{
cout << "Enter the name using the following order. (First name, middle name, last name):" << endl;
cin >> first_name >> middle_name >> last_name;
}
void output(char first_name, char middle_name, char last_name)
{
cout << "Here is the formatted name of the name you chose." << endl;
cout << last_name << " " << first_name << " " << middle_name << endl;
}
void change(char middle_name, char last_name)
{
if(last_name == " ")
{
last_name = middle_name + ',';
middle_name = " ";
}
else
{
last_name = last_name + ',';
middle_name = middle_name.strlen(0,1) + ".";
}
}
|