Provinces Of The Philippines

hi, can someone help me please... when i run my program... it only displays the first province...

//This Program Will Gives You The Information Of The Different Provinces Of The Philippines.
#include<iostream>
using namespace std;
int main()
{
string Province;

cout<< "Enter The Name Of The Province"<<endl;
cin>>Province;

if (Province == "Abra")
{
cout<< "Capital: Bangued"<<endl;
cout<< "Population: 241,160"<<endl;
cout<< "Area: 1,608.21 sq mi"<<endl;
cout<< "Density: 150/sq mi"<<endl;
cout<< "Founded: 9-March-17"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: CAR"<<endl;
}
if (Province == "Agusan Del Norte")
{
cout<< "Capital: Cabadbaran"<<endl;
cout<< "Population: 691,566"<<endl;
cout<< "Area: 1,369.45 sq mi"<<endl;
cout<< "Density: 490/sq mi"<<endl;
cout<< "Founded: 1-January-70"<<endl;
cout<< "Division: Mindanao"<<endl;
cout<< "Region: XIII"<<endl;
}
if (Province == "Agusan Del Sur")
{
cout<< "Capital: Properidad"<<endl;
cout<< "Population: 700,653"<<endl;
cout<< "Area: 3,856.98 sq mi"<<endl;
cout<< "Density: 180/sq mi"<<endl;
cout<< "Founded: 1-January-70"<<endl;
cout<< "Division: Mindanao"<<endl;
cout<< "Region: XII"<<endl;
}
if (Province == "Aklan")
{
cout<< "Capital: Kalibo"<<endl;
cout<< "Population: 574,823"<<endl;
cout<< "Area: 703.25 sq mi"<<endl;
cout<< "Density: 830/sq mi"<<endl;
cout<< "Founded: 8-November-56"<<endl;
cout<< "Division: Visayas"<<endl;
cout<< "Region: VI"<<endl;
}
if (Province == "Albay")
{
cout<< "Capital: Legazpi"<<endl;
cout<< "Population: 1,314,826"<<endl;
cout<< "Area: 994.51 sq mi"<<endl;
cout<< "Density: 1,300/sq mi"<<endl;
cout<< "Founded: 3-April-74"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: V"<<endl;
}
if (Province == "Antique")
{
cout<< "Capital: San Jose"<<endl;
cout<< "Population: 582,012"<<endl;
cout<< "Area: 1,053.74 sq mi"<<endl;
cout<< "Density: 540/sq mi"<<endl;
cout<< "Founded: 10-March-17"<<endl;
cout<< "Division: Visayas"<<endl;
cout<< "Region: VI"<<endl;
}
if (Province == "Apayao")
{
cout<< "Capital: Kabugao"<<endl;
cout<< "Population: 119,184"<<endl;
cout<< "Area: 1,704.00 sq mi"<<endl;
cout<< "Density: 70/sq mi"<<endl;
cout<< "Founded: 14-February-95"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: CAR"<<endl;
}
if (Province == "Aurora")
{
cout<< "Capital: Baler"<<endl;
cout<< "Population: 214,336"<<endl;
cout<< "Area: 1,215.19 sq mi"<<endl;
cout<< "Density: 180/sq mi"<<endl;
cout<< "Founded: 13-August-79"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: III"<<endl;
}
if (Province == "Basilan")
{
cout<< "Capital: Isabela"<<endl;
cout<< "Population: 459,367"<<endl;
cout<< "Area: 532.44 sq mi"<<endl;
cout<< "Density: 850/sq mi"<<endl;
cout<< "Founded: 27-December-73"<<endl;
cout<< "Division: Mindanao"<<endl;
cout<< "Region: ARMM"<<endl;
}
if (Province == "Bataan")
{
cout<< "Capital: Balanga"<<endl;
cout<< "Population: 760,650"<<endl;
cout<< "Area: 530.11 sq mi"<<endl;
cout<< "Density: 550/sq mi"<<endl;
cout<< "Founded: 1754"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: III"<<endl;
}
if (Province == "Batanes")
{
cout<< "Capital: Basco"<<endl;
cout<< "Population: 17,246"<<endl;
cout<< "Area: 84.56 sq mi"<<endl;
cout<< "Density: 200/sq mi"<<endl;
cout<< "Founded: 26-June-1783"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: II"<<endl;
}
if (Province == "Batangas")
{
cout<< "Capital: Batangas City"<<endl;
cout<< "Population: 2,694,335"<<endl;
cout<< "Area: 1,204.53 sq mi"<<endl;
cout<< "Density: 2,200/sq mi"<<endl;
cout<< "Founded: 8-December-1581"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: IV-A"<<endl;
}
if (Province == "Benguet")
{
cout<< "Capital: La Trinidad"<<endl;
cout<< "Population: 761,590"<<endl;
cout<< "Area: 1,091.35 sq mi"<<endl;
cout<< "Density: 750/sq mi"<<endl;
cout<< "Founded: 16-June-1966"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: CAR"<<endl;
}
if (Province == "Biliran")
{
cout<< "Capital: Naval"<<endl;
cout<< "Population: 171,612"<<endl;
cout<< "Area: 206.95 sq mi"<<endl;
cout<< "Density: 830/sq mi"<<endl;
cout<< "Founded: 11-May-92"<<endl;
cout<< "Division: Visayas"<<endl;
cout<< "Region: VIII"<<endl;
}
if (Province == "Bohol")
{
cout<< "Capital: Tagbiliran"<<endl;
cout<< "Population: 1,313,560"<<endl;
cout<< "Area: 1,861.38 sq mi"<<endl;
cout<< "Density: 700/sq mi"<<endl;
cout<< "Founded: 22-July-1854"<<endl;
cout<< "Division: Visayas"<<endl;
cout<< "Region: VII"<<endl;
}
if (Province == "Bukidnon")
{
cout<< "Capital: Malaybalay"<<endl;
cout<< "Population: 1,415,226"<<endl;
cout<< "Area: 4,053.53 sq mi"<<endl;
cout<< "Density: 340/sq mi"<<endl;
cout<< "Founded: 1-September-14"<<endl;
cout<< "Division: Mindanao"<<endl;
cout<< "Region: X"<<endl;
}
if (Province == "Bulacan")
{
cout<< "Capital: Malolos"<<endl;
cout<< "Population: 3,292,071"<<endl;
cout<< "Area: 1,079.58 sq mi"<<endl;
cout<< "Density: 3,100/sq mi"<<endl;
cout<< "Founded: 15-August-1578"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: III"<<endl;
}
if (Province == "Cagayan")
{
cout<< "Capital: Tuguegarao"<<endl;
cout<< "Population: 1,199,320"<<endl;
cout<< "Area: 3,589.11 sq mi"<<endl;
cout<< "Density: 340/sq mi"<<endl;
cout<< "Founded: 29-June-1583"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: II"<<endl;
}
if (Province == "Camarines Norte")
{
cout<< "Capital: Daet"<<endl;
cout<< "Population: 583,313"<<endl;
cout<< "Area: 895.78 sq mi"<<endl;
cout<< "Density: 650/sq mi"<<endl;
cout<< "Founded: 15-April-20"<<endl;
cout<< "Division: Luzon"<<endl;
cout<< "Region: V"<<endl;
}


}
else
return 0;
}
std::cin will only read input up to the first whitespace (In this case the ' ' between some names).

So lets say when you run the program you enter in "Agusan Del Norte", what is actually being stored in your Province variable is this "Agusan".

If you want to grab the input up until the first newline for example you will need to look into using std::getline() http://www.cplusplus.com/reference/string/string/getline/ .

Edit: Also you have an extra } at the end of you program (Right above your else condition) that you don't need (You should be getting an error for it). So get rid of that and also the else condition which isn't doing anything here (You can you if brackets without the else statement, if the if condition doesn't evaluate to true it will just skip everything inside of that if's brackets and continue with the next line of execution).

And one last thing, when you post your code on this forum surround it with code tags, this can be done by either highlighting all your code and clicking the <> button in the format section. Or you can type it like this [code.]Your code here[/.code], just remove the .'s that I put in there.

Doing this makes it much easier to read the code since it is formatted like this.
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// Your code with the changes I mentioned above (Removing the else and extra })

//This Program Will Gives You The Information Of The Different Provinces Of The Philippines.
#include<iostream>
using namespace std;
int main()
{
	string Province;

	cout<< "Enter The Name Of The Province"<<endl;
	cin>>Province;

	if (Province == "Abra")
	{
		cout<< "Capital: Bangued"<<endl;
		cout<< "Population: 241,160"<<endl;
		cout<< "Area: 1,608.21 sq mi"<<endl;
		cout<< "Density: 150/sq mi"<<endl;
		cout<< "Founded: 9-March-17"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: CAR"<<endl;
	}
	
	if (Province == "Agusan Del Norte")
	{
		cout<< "Capital: Cabadbaran"<<endl;
		cout<< "Population: 691,566"<<endl;
		cout<< "Area: 1,369.45 sq mi"<<endl;
		cout<< "Density: 490/sq mi"<<endl;
		cout<< "Founded: 1-January-70"<<endl;
		cout<< "Division: Mindanao"<<endl;
		cout<< "Region: XIII"<<endl;
	}
	
	if (Province == "Agusan Del Sur")
	{
		cout<< "Capital: Properidad"<<endl;
		cout<< "Population: 700,653"<<endl;
		cout<< "Area: 3,856.98 sq mi"<<endl;
		cout<< "Density: 180/sq mi"<<endl;
		cout<< "Founded: 1-January-70"<<endl;
		cout<< "Division: Mindanao"<<endl;
		cout<< "Region: XII"<<endl;
	}
	
	if (Province == "Aklan")
	{
		cout<< "Capital: Kalibo"<<endl;
		cout<< "Population: 574,823"<<endl;
		cout<< "Area: 703.25 sq mi"<<endl;
		cout<< "Density: 830/sq mi"<<endl;
		cout<< "Founded: 8-November-56"<<endl;
		cout<< "Division: Visayas"<<endl;
		cout<< "Region: VI"<<endl;
	}
	
	if (Province == "Albay")
	{
		cout<< "Capital: Legazpi"<<endl;
		cout<< "Population: 1,314,826"<<endl;
		cout<< "Area: 994.51 sq mi"<<endl;
		cout<< "Density: 1,300/sq mi"<<endl;
		cout<< "Founded: 3-April-74"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: V"<<endl;
	}
	
	if (Province == "Antique")
	{
		cout<< "Capital: San Jose"<<endl;
		cout<< "Population: 582,012"<<endl;
		cout<< "Area: 1,053.74 sq mi"<<endl;
		cout<< "Density: 540/sq mi"<<endl;
		cout<< "Founded: 10-March-17"<<endl;
		cout<< "Division: Visayas"<<endl;
		cout<< "Region: VI"<<endl;
	}
	
	if (Province == "Apayao")
	{
		cout<< "Capital: Kabugao"<<endl;
		cout<< "Population: 119,184"<<endl;
		cout<< "Area: 1,704.00 sq mi"<<endl;
		cout<< "Density: 70/sq mi"<<endl;
		cout<< "Founded: 14-February-95"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: CAR"<<endl;
	}
	
	if (Province == "Aurora")
	{
		cout<< "Capital: Baler"<<endl;
		cout<< "Population: 214,336"<<endl;
		cout<< "Area: 1,215.19 sq mi"<<endl;
		cout<< "Density: 180/sq mi"<<endl;
		cout<< "Founded: 13-August-79"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: III"<<endl;
	}
	
	if (Province == "Basilan")
	{
		cout<< "Capital: Isabela"<<endl;
		cout<< "Population: 459,367"<<endl;
		cout<< "Area: 532.44 sq mi"<<endl;
		cout<< "Density: 850/sq mi"<<endl;
		cout<< "Founded: 27-December-73"<<endl;
		cout<< "Division: Mindanao"<<endl;
		cout<< "Region: ARMM"<<endl;
	}
	
	if (Province == "Bataan")
	{
		cout<< "Capital: Balanga"<<endl;
		cout<< "Population: 760,650"<<endl;
		cout<< "Area: 530.11 sq mi"<<endl;
		cout<< "Density: 550/sq mi"<<endl;
		cout<< "Founded: 1754"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: III"<<endl;
	}
	
	if (Province == "Batanes")
	{
		cout<< "Capital: Basco"<<endl;
		cout<< "Population: 17,246"<<endl;
		cout<< "Area: 84.56 sq mi"<<endl;
		cout<< "Density: 200/sq mi"<<endl;
		cout<< "Founded: 26-June-1783"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: II"<<endl;
	}
	
	if (Province == "Batangas")
	{
		cout<< "Capital: Batangas City"<<endl;
		cout<< "Population: 2,694,335"<<endl;
		cout<< "Area: 1,204.53 sq mi"<<endl;
		cout<< "Density: 2,200/sq mi"<<endl;
		cout<< "Founded: 8-December-1581"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: IV-A"<<endl;
	}
	
	if (Province == "Benguet")
	{
		cout<< "Capital: La Trinidad"<<endl;
		cout<< "Population: 761,590"<<endl;
		cout<< "Area: 1,091.35 sq mi"<<endl;
		cout<< "Density: 750/sq mi"<<endl;
		cout<< "Founded: 16-June-1966"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: CAR"<<endl;
	}
	
	if (Province == "Biliran")
	{
		cout<< "Capital: Naval"<<endl;
		cout<< "Population: 171,612"<<endl;
		cout<< "Area: 206.95 sq mi"<<endl;
		cout<< "Density: 830/sq mi"<<endl;
		cout<< "Founded: 11-May-92"<<endl;
		cout<< "Division: Visayas"<<endl;
		cout<< "Region: VIII"<<endl;
	}
	
	if (Province == "Bohol")
	{
		cout<< "Capital: Tagbiliran"<<endl;
		cout<< "Population: 1,313,560"<<endl;
		cout<< "Area: 1,861.38 sq mi"<<endl;
		cout<< "Density: 700/sq mi"<<endl;
		cout<< "Founded: 22-July-1854"<<endl;
		cout<< "Division: Visayas"<<endl;
		cout<< "Region: VII"<<endl;
	}
	
	if (Province == "Bukidnon")
	{
		cout<< "Capital: Malaybalay"<<endl;
		cout<< "Population: 1,415,226"<<endl;
		cout<< "Area: 4,053.53 sq mi"<<endl;
		cout<< "Density: 340/sq mi"<<endl;
		cout<< "Founded: 1-September-14"<<endl;
		cout<< "Division: Mindanao"<<endl;
		cout<< "Region: X"<<endl;
	}
	
	if (Province == "Bulacan")
	{
		cout<< "Capital: Malolos"<<endl;
		cout<< "Population: 3,292,071"<<endl;
		cout<< "Area: 1,079.58 sq mi"<<endl;
		cout<< "Density: 3,100/sq mi"<<endl;
		cout<< "Founded: 15-August-1578"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: III"<<endl;
	}
	
	if (Province == "Cagayan")
	{
		cout<< "Capital: Tuguegarao"<<endl;
		cout<< "Population: 1,199,320"<<endl;
		cout<< "Area: 3,589.11 sq mi"<<endl;
		cout<< "Density: 340/sq mi"<<endl;
		cout<< "Founded: 29-June-1583"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: II"<<endl;
	}
	
	if (Province == "Camarines Norte")
	{
		cout<< "Capital: Daet"<<endl;
		cout<< "Population: 583,313"<<endl;
		cout<< "Area: 895.78 sq mi"<<endl;
		cout<< "Density: 650/sq mi"<<endl;
		cout<< "Founded: 15-April-20"<<endl;
		cout<< "Division: Luzon"<<endl;
		cout<< "Region: V"<<endl;
	}
	
	

	return 0;
}
Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/195794/
ohhh thank you that helps me a lot

sorry... okay i will display it like that next time thank you...
can you help me how to properly program it... cause i'm really new at programming i'm only at my 1st year in college? please...
Don't do duplicate Topics, that was the point of kemort's post. It is ultimately a time waster for those who reply.
Topic archived. No new replies allowed.