Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

When can the potential difference across a resistor be positive?

Answered: 1 week ago

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago