using namespace std;


int numCheck(int x);

int main ()
{   

    const double LAWYER = 0.10, PERSONAL_ASSISTANT = 0.03, AGENT = 0.07,
                 TRAINER = 0.05;

    double athleteBeginSalary(0.0), lawyerSalary(0.0), personalAssistantSalary(0.0), agentSalary(0.0),
           trainerSalary(0.0), professionalTotalSalary(0.0), athleteEndSalary(0.0);

    int numLawyer, numPersonalAssistant, numAgent, numTrainer, x(1), y(0);

    string firstName[8], lastName[8];



    // The number of the Professional hired: Lawyer, Personal Assistant, Agents, and Trainer //

    cout << "Enter the number of Lawyers hired: "; 
    cin >> numLawyer;
    while((numLawyer < 0) || (numLawyer > 2))
    {
    numLawyer = numCheck(numLawyer);
    }
    if(numLawyer != 0)
    {
                 cout << "Now enter the names of each Lawyer: \n";
                 for(int i = 0; i < numLawyer; i++, x++)
                 {
                  cout << "Lawyer " << x <<": ";
                  cin >> firstName[i] >> lastName[i];
                  }
    }


    cout << "Enter the number of Personal Assistants hired: ";
    cin >> numPersonalAssistant;
    while((numPersonalAssistant < 0) || (numPersonalAssistant> 2))
    {
    numPersonalAssistant = numCheck(numPersonalAssistant);
    }
    if(numPersonalAssistant != 0)
    {
                            cout << "Now enter the names of each Personal Assistant: \n";
                            for(int i = 2, x = 1; i < (numPersonalAssistant + 2); i++, x++)
                            {
                             cout << "Personal Assistant " << x <<": ";
                             cin >> firstName[i] >> lastName[i];
                             }
    }


    cout << "Enter the number of Agents hired: ";
    cin >> numAgent;
    while((numAgent < 0) || (numAgent> 2))
    {
    numAgent = numCheck(numAgent);
    }
    if(numAgent != 0)
    {
                cout << "Now enter the names of each Agents: \n";
                for(int i = 4, x = 1; i < (numAgent + 4); i++, x++)
                {
                 cout << "Agent " << x <<": ";
                 cin >> firstName[i] >> lastName[i];
                 }
    }

    cout << "Enter the number of Trainers hired: ";
    cin >> numTrainer;
    while((numTrainer < 0) || (numTrainer> 2))
    {
    numTrainer = numCheck(numTrainer);
    }
    if(numTrainer != 0)
    {

                  cout << "Now enter the names of each Trainer: \n";
                  for(int i = 6, x = 1; i < (numTrainer + 6); i++, x++)
                  {
                   cout << "Trainer " << x <<": ";
                   cin >> firstName[i] >> lastName[i];
                   }
    }

    for(int i = 0; i < 8; i++)
    {
            cout << firstName[i] <<" "<<lastName[i]<<"\n";
    }

    // Enter Salary of the Athlete, Lawyer, Personal Assistant, Agent and Trainer //

    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);

    cout << "Enter the athlete begininng salary for the year: " << "$";
    cin >> athleteBeginSalary;

    lawyerSalary = (athleteBeginSalary * 0.10) * (numLawyer);
    personalAssistantSalary = (athleteBeginSalary * 0.03) * (numPersonalAssistant);
    agentSalary = (athleteBeginSalary * 0.07) * (numAgent);
    trainerSalary = (athleteBeginSalary * 0.05) * (numTrainer);
    professionalTotalSalary = (lawyerSalary + personalAssistantSalary + agentSalary + trainerSalary);
    athleteEndSalary = ( athleteBeginSalary - professionalTotalSalary); 

    cout <<"\n If no value is displayed under a category, then no value was entered.\n";

    cout << endl << endl;

    cout << "LAWYER(S) PAY: \n";
    for(int i = 0; i < numLawyer; i++)
    {
    cout << firstName[i] <<" "<< lastName[i] << ": $" << (lawyerSalary/numLawyer)<< endl;
    }

    cout << endl << endl; 


    cout << "PERSONAL ASSISTANT(S) PAY:  \n";
    for (int i = 2; i < numPersonalAssistant + 2; i++)
    {
    cout << firstName[i] << " " << lastName[i] << ": $" << personalAssistantSalary/numPersonalAssistant << endl;
    }

    cout << endl << endl;

    cout << "AGENT (S) PAY: \n";
    for (int i = 4; i < numAgent + 4; i++)
    {
    cout << firstName[i] << " " << lastName[i] << ": $" << agentSalary/numAgent << endl;
    }

    cout << endl << endl;


    cout << "TRAINER (S) PAY:  \n";
    for (int i = 6; i < numTrainer + 6; i++)
    {
    cout << firstName[i] << " " << lastName[i] << ": $" << trainerSalary/numTrainer << endl;
    }

    cout << endl << endl;


    cout << "The total amount paid to the hired professional is " << " $ " << professionalTotalSalary << endl;

    cout << endl << endl;

    cout << "The Ending salary of the athlete is " << " $ " << athleteEndSalary << endl;




    system("pause");
    return 0;

}

int numCheck(int x)
{
             int y;
             if((x < 0)||(x > 2))
             {
                  cout << "Invalid Number! Number Must Be Not Less Than 0" 
                       << "or Greater Than 2. Please Enter A Valid Number: ";
                  cin >> y;
             }
             return(y);
}

Dani AI

Generated

Quick summary and practical fixes for 's program: the posted code has three classes of problems you can fix quickly — missing/incorrect headers (compilation failure), unsafe input handling that can produce undefined behavior, and fragile indexing/logic that will confuse maintenance and can produce runtime errors. already spotted the missing header; 's idea of an OOP rewrite is a good direction for longer-term cleanup, but a few small, concrete changes make the current program robust.

Replace the current numCheck with a function that validates input, rejects non-numeric input, and loops until a value in 0..2 is provided. For example:

int readCount(const char* prompt)
{
    int v;
    while (true) {
        std::cout << prompt;
        if (!(std::cin >> v)) {
            std::cin.clear();
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
            std::cout << "Please enter a number 0 to 2.\n";
            continue;
        }
        if (v >= 0 && v <= 2) return v;
        std::cout << "Value must be between 0 and 2.\n";
    }
}

Other actionable points:

  • Don’t rely on fixed index slots in firstName/lastName; use std::vector or small structs per profession so you only print what was entered and avoid magic indices (0..7).
  • Always check counts before dividing (avoid divide-by-zero) and handle I/O failures gracefully.
  • Replace system("pause") with a portable pause (e.g., read a line) if you need to wait for user input.
  • Use named constants (constexpr) for the percentage rates and consider storing money as integer cents if exactness matters.

Checklist: add appropriate headers, swap numCheck for the validated reader above, convert per-profession storage to vectors/structs, guard divisions, and consider 's OOP refactor when you have time.

Recommended Answers

All 8 Replies

Two pigs in a barn:

#include <iostream>
int main()
{
  using std::cout;
  cout << "Eggs eat stonks"

  int a = 65;
  int b = a/3;
}

Wait, what are the rules of this game again?

Nice, Moschops.
For amusement, I am rewriting infamous1987's post as a proper OOP program.
I'll let you know when I'm done.

But what ARE the rules?

Well, you broke the first one by using the CODE tag.

The first rule of Athlete's Salary is you DO NOT TALK ABOUT Athlete's Salary

lol thanks for the help

You're welcome.

If you place #include <iostream> there the program actually works...

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.