Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class customerdata
- {
- private:
- int id;
- int age;
- int creditcard;
- int phonenumber;
- public:
- void fillvalues()
- {
- age = 20 + rand() % 41; // random: 20 - 60
- creditcard = 1000 + rand() % 9000; // random: 1000 - 9999
- phonenumber = 1000000 + rand() % 9000000; // random: 1000000 - 9999999
- }
- void setid(int val)
- {
- id = val;
- }
- int securitypreference()
- {
- return rand() % 2; // returns: 0 or 1
- }
- void printsecure()
- {
- cout << "Customer id: " << id << endl;
- cout << "Customer age: " << age << endl;
- cout << endl;
- }
- void printall()
- {
- cout << "Customer id: " << id << endl;
- cout << "Customer age: " << age << endl;
- cout << "Last 4 digits of card #: " << creditcard << endl;
- cout << "Customer phone number: " << phonenumber << endl;
- cout << endl;
- }
- };
- int main()
- {
- int input;
- int i;
- customerdata myarray[50];
- for (i=0; i<50; i++)
- {
- myarray[i].setid(i);
- myarray[i].fillvalues();
- }
- while(1)
- {
- cout << "Enter customer id (0 to 49): ";
- cin >> input;
- // 1: secure, 0: not_secure
- if (myarray[input].securitypreference() == 1)
- {
- myarray[input].printsecure();
- }
- else
- {
- myarray[input].printall();
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment