#include <string>
#include <iostream>
#include <cmath>

using namespace std;

const int findMe (string n[MAXIMUM = 100], double scor[MAXIMUM = 100],)
{



}
int main ()
{
 
    string names[MAXIMUM];
    double score[MAXIMUM];

    for (int x = 0; x < MAXIMUM; x++)
    {
        cout << "Please enter a student name (Enter a blank to stop): ";
        getline(cin, names[x]);
        cout << "Please enter this student's score: ";
        cin >> score[x];
        cin.ignore();
    }

    cout << endl << "*****************" << endl;

    while (true)
    {
        string lookmeup;
        double tmpscore;
        cout << "Enter a name to look up: ";
        getline(cin, lookmeup);
        if (findMe(lookmeup, names, score, tmpscore))
            cout << lookmeup << " has a score of " << tmpscore << endl;
        else
            cout << lookmeup << " was not found." << endl;
    }
}

I am trying to get output like this:

Please enter a student name (Enter a blank to stop): Adam
Please enter this student's score: 11.11
Please enter a student name (Enter a blank to stop): Betty
Please enter this student's score: 22.22
Please enter a student name (Enter a blank to stop): Charlie
Please enter this student's score: 33.33
Please enter a student name (Enter a blank to stop): Debbie
Please enter this student's score: 44.44
Please enter a student name (Enter a blank to stop): Elaine
Please enter this student's score: 55.55
Please enter a student name (Enter a blank to stop):

*****************
Enter a name to look up: Adam
Adam has a score of 11.11
Enter a name to look up: Elaine
Elaine has a score of 55.55
Enter a name to look up: Bob
Bob was not found.
Enter a name to look up: Charlie
Charlie has a score of 33.33
Enter a name to look up:

I dont know how to go about my function and am not sure how I can stop the loop with just a blank space. Also just wanted to see if my main is mostly correct.

Thanks for a any help

also did this to the top

const int findMe (string lookup, string name, int scores, int tempscores)
{



}

1) Add a line like:
const int MAXIMUM = 100;
at the start of main().

2) Remove MAXIMUM from the prototype for findMe

3) Be sure the number of parameters for findMe() are the same in the declaration and the function call---as posted they aren't.

4) You don't check for a blank in the input of the students name, you don't indciate what blank means-----do you mean just push the enter/carraige return key or do you mean just enter a space character, you don't provide an escape from the loop if user enters a blank before MAXIMUM number of loops is completed, and if the user can stop entry prior to MAXIMUM then you should probably keep track of the actual number of entries, which may or may not be MAXIMUM.

#include <iostream> 
#include <string>
#include <cmath>

using namespace std;

const int MAXIMUM = 100;

int findMe(string a, string b, double c, double d)
{
    while (true)
    {
        cout << "Enter a name to look up: ";
        getline(cin, a);
        if (findMe(a, b, c, d))
            cout << a << " has a score of " << d << endl;
        else
            cout << a << " was not found." << endl;
    }
    return 0;


}

int main ()
{
    string names[MAXIMUM];
    double score[MAXIMUM];

    for (int x = 0; x < MAXIMUM; x++)
    {
        cout << "Please enter a student name (Enter a blank to stop): ";
        getline(cin, names[x]);
        cout << "Please enter this student's score: ";
        cin >> score[x];
        cin.ignore();
    } 

    cout << endl << "*****************" << endl;

    while (!names[MAXIMUM].empty())

    {
        string lookmeup;
        double tmpscore = 0;
        cout << "Enter a name to look up: ";
        getline(cin, lookmeup);
        if (findMe(lookmeup, names[100], score[100], tmpscore))
            cout << lookmeup << " has a score of " << tmpscore << endl;
        else
            cout << lookmeup << " was not found." << endl;
    }
}

it runs, but the second part is not working.. any idea?

#include <string>
#include <iostream>
#include <cmath>

using namespace std;

const int findMe (string n[MAXIMUM = 100], double scor[MAXIMUM = 100],)
{



}
int main ()
{
 
    string names[MAXIMUM];
    double score[MAXIMUM];

    for (int x = 0; x < MAXIMUM; x++)
    {
        cout << "Please enter a student name (Enter a blank to stop): ";
        getline(cin, names[x]);
        cout << "Please enter this student's score: ";
        cin >> score[x];
        cin.ignore();
    }

    cout << endl << "*****************" << endl;

    while (true)
    {
        string lookmeup;
        double tmpscore;
        cout << "Enter a name to look up: ";
        getline(cin, lookmeup);
        if (findMe(lookmeup, names, score, tmpscore))
            cout << lookmeup << " has a score of " << tmpscore << endl;
        else
            cout << lookmeup << " was not found." << endl;
    }
}

I am trying to get output like this:

Please enter a student name (Enter a blank to stop): Adam
Please enter this student's score: 11.11
Please enter a student name (Enter a blank to stop): Betty
Please enter this student's score: 22.22
Please enter a student name (Enter a blank to stop): Charlie
Please enter this student's score: 33.33
Please enter a student name (Enter a blank to stop): Debbie
Please enter this student's score: 44.44
Please enter a student name (Enter a blank to stop): Elaine
Please enter this student's score: 55.55
Please enter a student name (Enter a blank to stop):

*****************
Enter a name to look up: Adam
Adam has a score of 11.11
Enter a name to look up: Elaine
Elaine has a score of 55.55
Enter a name to look up: Bob
Bob was not found.
Enter a name to look up: Charlie
Charlie has a score of 33.33
Enter a name to look up:

I dont know how to go about my function and am not sure how I can stop the loop with just a blank space. Also just wanted to see if my main is mostly correct.

Thanks for a any help

This one runs, but second part won't work, any ideas?

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

const int MAXIMUM = 100;

int findMe(string a, string b, double c, double d)
{
while (true)
{
cout << "Enter a name to look up: ";
getline(cin, a);
if (findMe(a, b, c, d))
cout << a << " has a score of " << d << endl;
else
cout << a << " was not found." << endl;
}
return 0;


}

int main ()
{
string names[MAXIMUM];
double score[MAXIMUM];

for (int x = 0; x < MAXIMUM; x++)
{
cout << "Please enter a student name (Enter a blank to stop): ";
getline(cin, names[x]);
cout << "Please enter this student's score: ";
cin >> score[x];
cin.ignore();
}

cout << endl << "*****************" << endl;

while (!names[MAXIMUM].empty())

{
string lookmeup;
double tmpscore = 0;
cout << "Enter a name to look up: ";
getline(cin, lookmeup);
if (findMe(lookmeup, names[100], score[100], tmpscore))
cout << lookmeup << " has a score of " << tmpscore << endl;
else
cout << lookmeup << " was not found." << endl;
}
}

string lookmeup;
double tmpscore;
bool more = true;
char choice;
while (more)
{
   if (findMe(lookmeup, names, score, tmpscore, size))
      cout << lookmeup << " has a score of " << tmpscore << endl;
  else
     cout << lookmeup << " was not found." << endl;

   cout << "enter any key but Y to stop" << endl;
   cin >> choice;
   if(choice != Y)
     more = false;
}

bool findMe(string & lookmeup, string * b, double * c, double & tmpscore, int size)
{
   bool found = false;
   cout << "Enter a name to look up: ";
   cin.ignore(1024);
   getline(cin, lookmeup);

   for(int i = 0; i < size; ++i)
   {
     if(names[i] == lookmeup)
     {
        tmpscore = score[i]
        found = true;
        break;
     }
   }
  return found;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.