//Ryan Shahriyarpour CS1A Chapter 10 Question 7
/*****************************************************************************
*
* Name Arranger
*
*********************
*
* This program asks for the user's first, middle, and last names, each
* stored in its own character array. It then builds a fourth array holding
* the name arranged as: last name, a comma and a space, first name, a
* space, then the middle name.
* For example, "Carol Lynn Smith" becomes "Smith, Carol Lynn".
*
* INPUT
* firstName - the user's first name
* middleName - the user's middle name
* lastName - the user's last name
*
* OUTPUT
* The name arranged as "Last, First Middle"
*
****************************************************************************/
#include <iostream>
#include <cstring>
using namespace std;
// Constants for the array sizes
const int NAME_SIZE = 30; // size of each individual name array
const int FULL_SIZE = 100; // size of the arranged name array
int main()
{
// DATA DICTIONARY
// NAME_SIZE - size of the first, middle, and last name arrays (constant)
// FULL_SIZE - size of the arranged name array (constant)
// firstName - the user's first name
// middleName - the user's middle name
// lastName - the user's last name
// fullName - the arranged name: last, first middle
char firstName[NAME_SIZE];
char middleName[NAME_SIZE];
char lastName[NAME_SIZE];
char fullName[FULL_SIZE];
// Get the three names
cout << "Enter your first name: ";
cin.getline(firstName, NAME_SIZE);
cout << "Enter your middle name: ";
cin.getline(middleName, NAME_SIZE);
cout << "Enter your last name: ";
cin.getline(lastName, NAME_SIZE);
// Build the arranged name: Last, First Middle
strcpy(fullName, lastName);
strcat(fullName, ", ");
strcat(fullName, firstName);
strcat(fullName, " ");
strcat(fullName, middleName);
// Display the arranged name
cout << "\nArranged name: " << fullName << endl;
return 0;
}