/*
5-40 String is on the List?
Design a function() to Confirm that a Certain String is on a List.
*/
#include <iostream>
#include <string>
usingnamespace std;
string one (string a, string b, string c)
{
returnif ( a == "two" )
{cout << "You got it! It was two!\n";}
elseif ( b == "two" )
{cout << "You got it! It was two!\n";}
elseif ( c == "two" )
{cout << "You got it! It was two!\n";}
else
{cout << "Try again!\n";};;
}
void main()
{
string one, two, three;
cout << "Give me a list of three numbers, spelled out, and I'll tell you if you have the number on my mind.\n";
cout << "enter first number: \n";
cin >> one;
cout << "enter second number: \n";
cin >> two;
cout << "enter third number: \n";
cin >> three;
cout >> string (one);
system ("pause");
}
Second of all, the function's not written correctly...
1 2 3 4 5 6 7
void one (string a, string b, string c)
{
if (a == "two" || b == "two" || c == "two") // No "return"
cout << "You got it! It was two!\n";
else
cout << "Try again!\n";
}
Third of all, you have a function named "one", and also a string variable named "one".
You can't do that...(in other words, rename the function).
And fourth of all, you're not calling it correctly. (on line 35)
You should be calling it like theNewNameOfMyFunctionHere(one, two, three); // No cout
Of course, that's not exactly how I would've written this program, but this will at least fix your error(s). (and give you the correct output)
Try to fix the errors first,then try other alternatives...be innovative(thats why you're called a computer scientist),now if it doesnt work--call for help.People will help by then