// Lab 2, Creating a Palindrome
// Programmer:
// Editor(s) used: XP Notepad
// Compiler(s) used: VC++ 2010 Express
// preprocessor directive for streaming, variable, and ending statement.
#include <iostream>
using std::cin;
using std::cout;
using std::ios;
using std::endl;
// preprocessor directive for string, and variable string.
#include <string>
using std::string;
using std::getline;
#include <cstdlib>
int main() {
//Jesse Burns program number 2: creating palindrome.
cout << "Lab 2, creating a Palindrome" <<endl;
cout << "Programmer:" <<endl;
cout << "Editor(s) used: XP Notepad" <<endl;
cout << "Compiler(s) used: VC++ 2010 Express" <<endl;
//Create a while loop so the information can loop back and return
while(true)
{
//The variables needed to input and compare information.
int a;
int b;
int n;
string buf;
//Entering the information.
cout << "Enter a five digit number to determine a palindrome or press q to quit."<<endl;
cin >> buf; n = atoi(buf.c_str());
cin.ignore(1000,10);
//The needed if statement for the loop to quit. Inluded the break statement as well.
if(buf == "Q" || buf == "q")break;
{
//The math to compare the opposite ends.
a = n % 10;
b = n / 1000;
//Actually comparing the opposite numbers.
if (a == b)continue;
//The math needed to compare the inner numbers
a = n % 10;
b = n / 100;
//The if statement for the inner numbers
if (a == b)
{
cout << "The palindrome you enter is "<< n <<"."<<endl;
}
}
}
cout << "Press enter to continue..."<<endl;
cin.get();
}