I had to define a class named Customer that holds private fields for Customer ID number, last name, first name, and credit limit. There had to be four private functions that each set one of the four fields. Credit limits could not be over $10,000. Then a public function had to be included that would display the Customer's data. The main() program is where I had to declare a Customer, set the Customer's fields and display the results. I have completed this part sucessfully without error, at least it ran anyway.
Now I have to write a main() program that delcares an array of five Customers. I have to set all of the fields for each Customer, and display values for all five Customer objects. But I am so lost, I am not good with arrays at allCode:#include<iostream.h> #include<conio.h> #include<string.h> class Customer { private: int customerIdNum; char lastName[15]; char firstName[15]; double creditLimit; public: void displayCustomerData(); void setCustomerIdNum(int num); void setLastName(char name[]); void setFirstName(char name[]); void setCreditLimit(double CL); }; //implementation section void Customer::displayCustomerData() { cout<<"Customer ID Number "<<customerIdNum<<"'s first name is "<<firstName<<endl; cout<<firstName<<"'s last name is "<<lastName<<endl; cout<<"The credit limit for this customer is $"<<creditLimit<<endl; } void Customer::setCreditLimit(double CL) { if( CL < 10000) creditLimit = CL; else creditLimit = 9999; } void Customer::setLastName(char name[]) { strcpy(lastName, name); } void Customer::setFirstName(char name[]) { strcpy(firstName, name); } void Customer::setCustomerIdNum(int num) { if ( customerIdNum < 10000) customerIdNum = num; else customerIdNum = 9999; } void main() { Customer aCustomer; aCustomer.setCreditLimit(7000); aCustomer.setLastName("Andrews"); aCustomer.setFirstName("Melissa"); aCustomer.setCustomerIdNum(754); aCustomer.displayCustomerData(); getch(); }
Can anyone help?