Write a function of print_customer and print list of customers whose age is between 18 and 30, or whose gender is female. Attributes of customer are name, age and gender
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
class customer{
public:
string name;
int age;
string gender;
void input()
{
cout<<"Enter name : ";
cin>>name;
cout<<"Enter age : ";
cin>>age;
cout<<"Enter gender : ";
cin>>gender;
}
void primt_customer()
{
cout<<name<<setw(10)<<age<<setw(10)<<gender<<endl;
}
};
int main()
{
cout<<"Enter number of customers : ";
int n;
cin>>n;
customer c[n];
cout<<endl<<"Enter Customer Details "<<endl;
for(int i=0; i<n; i++)
{
c[i].input();
cout<<endl;
}
cout<<"Name"<<setw(10)<<"age"<<setw(10)<<"Gender"<<endl;
cout<<"----------------------------------"<<endl;
for(int i=0; i<n; i++)
{
if(c[i].age>=18 && c[i].age<=30 && c[i].gender == "female")
{
c[i].primt_customer();
}
}
}
Comments
Leave a comment