plz see this code.i have to submit it tomorrw but i hav alotof work to do

can anyone tell me how to write function that has following specifcations.
search for a house that has some price and the price is not more then a specified amount. here is my programme


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  class houseInfo
{
	string ownersName;
	string adress;
	int bedrooms;
	long int price;
public:
	void getdata();
	void display();
	void available(houseInfo[],int);
	void search(houseInfo a[]);
};
void houseInfo::getdata()//scope resulation operator
{
	cout<<"Enter The Owner's Name:"<<endl;

	cin>>ownersName;

	cout<<"Enter The Adress:"<<endl;

	cin>>adress;

	cout<<"Enter The Bedrooms:"<<endl;

	cin>>bedrooms;

	cout<<"Enter The Price:"<<endl;

	cin>>price;
}
void houseInfo::display()
{
	cout<<"The Name Of The Owner Is:"<<' '<<ownersName<<endl;

	cout<<endl;

	cout<<"The Adress Of The Employer Is:"<<' '<<adress<<endl;

	cout<<endl;

	cout<<"The Number Of Bedrooms Are:"<<' '<<bedrooms<<endl;

	cout<<endl;

	cout<<"The Price Of The House Is:"<<' '<<price<<endl;
	cout<<endl;
	
}
void houseInfo::available(houseInfo a[],int size)
{
	houseInfo y;
	int i;
	
	for(i=0;i<5;i++)
	{
		for(int j=i+1;j<5;j++)
		{
			if(a[i].price<a[j].price)
			{
				y=a[i];
				a[i]=a[j];
				a[j]=y;
			}
		}
	}
}


void houseInfo::search(houseInfo a[])
{
	houseInfo z;
long int amount=0;
cout<<"please enter the price range"<<endl;
		cin>>amount;
		for(int i=0;i<5;i++)

		if(a[i].price<=amount)
		{
			cout<<a[i].price;//what houd i do here?how to search specific price of house
		}
}

int main()
{
	houseInfo house[5],x;

	cout<<"\t \t \t Wellcome To Real Estate Company"<<endl;
	cout<<"\t \t \t -----------------------------"<<endl<<endl;
	for(int i=0;i<5;i++){

		house[i].getdata();
	}

	x.available(house,5);
	for(int i=0;i<5;i++)
	{

		house[i].display();
	}
	getch();
		
     return 0;
}
closed account (D80DSL3A)
This is at least the 5th thread on this homework problem.

http://www.cplusplus.com/forum/beginner/112247/
http://www.cplusplus.com/forum/general/111966/
http://www.cplusplus.com/forum/general/111943/
http://www.cplusplus.com/forum/beginner/111944/

Mehdinaqvi is ignoring replies in most cases.
closed account (o3hC5Di1)
Hi there,

You will need to do the following:

- Create a function which takes the house array and a price as parameter
- Iterate the array "house" (i.e. use a for loop as you do to display the data)
- Check the price of the house against the price parameter

Please give that a try and come back to us with the code you have attempted if you need any further help.
Most of the things you need you have already done elsewhere in the program.

All the best,
NwN
Try to not procrastinate next time.
Topic archived. No new replies allowed.