I'm taking my first coding class and I've hit a road block. I'm writing a program that will need to pick out the second and third characters in a set of either 4 or 5 characters that gives a corresponding output based off the values it finds.
Here's an example of some of what I have thus far.
include <iostream>
#include <string>
using namespace std;
int main()
{ //start of main function
system("cls");
string parts = " ";
char input = ' ';
cout << "******** Part Number Program ********" << endl << endl;
cout << "Enter the part number (x to end): ";
getline(cin, parts);
while (parts != "x" || parts != "X")
{ //start while
if (parts.substr(1, 1) == "M" && parts.substr(2, 1) == "P")//start if
{
cout << "Mail - Prioity" << endl << endl;
}//end if
else if (parts.substr(1, 1) == "F" && parts.substr(2, 1) == "S")//start if
{
cout << "FedEx - Standard" << endl << endl;
}//end if
This works except with the exception of lowercase letters. For example, if I were to enter 7MP7 I'd get the output Mail-Prioity. However, if I enter 7mp7 I'd get my error message. Any suggestion on how I can fix this?