Problem: Printing weird characters instead of printing ID#s.
The program's function: Add a new client's name and a new ID, and then it is your choice if you want to print.
it compilers without errors
Code:
#include <iostream>
using namespace std;
class healthClubMaintain{
private:
string names[15];
string idnumbers[15];
int counter,counter2,i,s;
public:
void addClient(string,int);
void printClient();
healthClubMaintain() { // default constructor
counter = 0;
counter2 = 0;
}
};
void healthClubMaintain::addClient(string clientName, int clientIDNumber){
if (counter<15){
names[counter]=clientName;
counter++;
}
if (counter2<15){
idnumbers[counter2]=clientIDNumber;
counter2++;
}
}
void healthClubMaintain::printClient(){
i=0;
s=0;
while(i<counter){
cout << "client's name: " << names[i]<<endl;
cout << "ID#: " << idnumbers[s]<<endl;
i++;
s++;
}
}
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,clientIDNumber);
}
if ( number == 2){
Club.printClient();
}
}
}