Question: I'm trying to use a void function and search array to isolate characters of a user generated item number. Theitem number must total 5 characters

I'm trying to use a void function and search array to isolate characters of a user generated item number. Theitem number must total 5 characters and the middle character must be one of the listed letters. The item number will corrolate with a listed color. What am I doing wrong?

#include #include #include using std::string; using std::getline; using namespace std; using string middle(string str);

int main () { string part = "";

//Get item number then extrapolate cout << "Please enter item number: "; getline(cin, part); return 0; } //end of main function

void searchArray(); string colors[4] = {"BLUE", "RED", "GREEN", "WHITE"}; string part = "";

cout << "Please enter item number: "; getline(cin, part);

while (part.length() == 5); { if {(middle(part) == "B" || "b"); cout << "BLUE" << endl;} else if {(middle(part) == "R" || "r"); cout << "RED" << endl;} else if {(middle(part) == "G" || "g"); cout << "GREEN" << endl;} else if {(middle(part) == "W" || "w"); cout << "WHITE" << endl;} else {cout << "Invalid Item" << endl;} } else while {(part.length() != 5;) cout << "Invalid Item" << endl;} //end while }

return 0; } //end of void function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!