// Attached: Lab 2 - Program #1
// ===========================================================
// File: Lab2_Program1
// ===========================================================
// Programmer: Elaine Torrez
// Class: CMPR 121
// ===========================================================
#include <iostream>
#include <string>
using namespace std;
// ==== main ====================================================
//
// This program uses string variables to read a user's name
// and state, displays character counts, and compares names.
//
// =============================================================
int main()
{
// Variable declarations
string firstName = "";
string lastName = "";
string fullName = "";
string city = "";
// Input
cout << "Enter your first name: ";
getline(cin, firstName);
cout << "Enter your last name: ";
getline(cin, lastName);
cout << "Enter the state you live in: ";
getline(cin, city);
// Processing
fullName = firstName + " " + lastName;
// Output
cout << "Hi " << fullName << ". So you live in " << city << "." << endl;
cout << "Your first name has " << firstName.length()
<< " characters," << endl;
cout << "and your last name has " << lastName.length()
<< " characters." << endl;
if (firstName == lastName)
{
cout << "Your first and last names are the same." << endl;
}
else
{
cout << "Your first and last names are different." << endl;
}
cout << "Press any key to continue . . .";
cin.get();
return 0;
} // end of main()
// =============================================================