Answer to Question #200723 in C for M Kamran

Question #200723

 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


1
Expert's answer
2021-05-31T00:52:37-0400
#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();
		}
	}
}

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
APPROVED BY CLIENTS