I want to store 15 names in an array! but it doesn't seem working correctly... anyone can figure it out ?
The problem:
Every time I promote the program to enter a name it will only be stored in the first position in the array. For example, when I promote the program to enter 3 names then print them.. the program will only prints the last input, unlike what it supposed to do and print all inputs
Code:
#include <iostream>
using namespace std;
class healthClubMaintain{
private:
string Al[15];
string Al2[15];
int counter,i,s;
int classCleintName;
int classClientIDNumber;
public:
void addClient(string);
void printClient();
};
void healthClubMaintain::addClient(string clientName){
counter=0;
if (counter ==15){
cout << " STOP!";
}
else{
Al[counter]=clientName;
counter++;
}
}
void healthClubMaintain::printClient(){
cout<<Al[0];
cout <<Al[1];
}
int main(){
int number,loop=0;
int clientIDNumber,programNumber,approvalIDNumber,clientIDA,programNumberA;
string clientName,programName,approvalName;
healthClubMaintain Club;
while ( loop==0){
cout<< "Select one of the following option:"<<endl;
cout<< "(1) Add a new client to the program"<<endl;
cout<< "(2) print"<<endl;
cin >> number;
if ( number ==1 ){
cout << "Insert the client's name" << endl;
cin >> clientName;
// cout << "Insert a new ID" << endl;
// cin >>clientIDNumber;
Club.addClient(clientName);
}
if ( number == 2){
Club.printClient();
}
}
}