Answer to Question #282293 in C++ for harsh

Question #282293

Write a program that has a class ‘Customer’ to store records of 100 Customers of company “ABC” including following members: Data member: (1) Cust_id (2) Cust_name (3) Cust_address Member Functions: (1)getdata() (2)display() 


1
Expert's answer
2021-12-23T16:27:54-0500
#include <iostream>
#include <string>


using namespace std;


class Customer{
    int Cust_id;
    string Cust_name;
    string Cust_address;
    public:
    Customer(){}
    Customer(int id, string name, string addr): Cust_id(id), Cust_name(name), Cust_address(addr){}
    int getdata(){
        return Cust_id;
    }
    void display(){
        cout<<"Cust_id: "<<Cust_id<<"\n";
        cout<<"Cust_name: "<<Cust_name<<"\n";
        cout<<"Cust_address: "<<Cust_address<<"\n";
    }
};


int main(){
    Customer ABC[100];
    cout<<"Input details of 100 customers\n";
    int id;
    string name, addr;
    for(int i = 0; i < 100; i++){
        cout<<"Customer "<<i + 1<<endl;
        cout<<"Input id: ";
        cin>>id;
        cout<<"Input name: ";
        getline(cin, name);
        cout<<"Input address: ";
        cin>>addr;
        ABC[i] = Customer(id, name, addr);
    }
    cout<<"\nDisplaying customers...\n";
    for(int i = 0; i < 100; i++){
        cout<<"\nCustomer "<<i + 1<<"\n";
        ABC[i].display();
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog