Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am working on a assignment on C++ that deals with Boolean function, and I am having trouble figuring it out. The question is..

I am working on a assignment on C++ that deals with Boolean function, and I am having trouble figuring it out. The question is..

"The menu asks the user to enter an option. The user should be able to enter any string for the option. The first character of the string entered is upper-cased and used as the option. Examples: Enter an option: o converted to O and accepted Enter an option: only first character o is capitalized to O and accepted When an invalid option is entered, the program prints Invalid option, enter I, O, L or X! and repeats the input until a valid option Is entered. If it finds the given character, it returns true. If it does not find the character, it returns false. This can be used instead of a long list of conditional expressions. Ex: so we do NOT have to write: if (c !=X && c!=O && c!=L && for ever & ever && c !=Z) instead of if (!isValidOption(c,XOLZ))"

Basically it asks user to type in character X, O , L, or I. But if the user type in lowercase of those letters it will also accept the input and if they type a word (string) that starts with one of those letters it will also accept the input.

Our professor gave us a hint by providing-

string userInput;

char option;

cout

if (cin.peek() == ' ') cin.ignore();

getline(cin, userInput);

option = toupper(userInput[0]);

Example output is below.

image text in transcribed

What I have so far is below and I am kind of stuck on what to do next..

bool isValidOption(char option, string & valOptions) {

return true;

return false;

}

I - List our Inventory 0-Make an Order L - List al1 Orders made X - Exit Enter an option: what option? Inualid option enter I 0. L or X! Enter an option: try again? Invalid option. enter I. 0. L or ! Enter an option: ok this will worlk

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

Step: 3

blur-text-image

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

5. How we can improve our listening skills?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago