Provinces of the philippines

Pages: 12
hi, can someone help me please...
my when i run my porgram... 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;
}
Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/195795/
yes
so i can display all of the provinces
cause when i run my program it only displays the first province
closed account (48T7M4Gy)
Close off one of the threads please. You don't need to post your stuff multiple times as it wastes people's time by duplicating effort.

When there is a green tick on one then you might get some much needed help.
sorry
closed account (48T7M4Gy)
Ok.

Now, if you change all but the first if to else if then you might get a bit more out of you program.

Try that but your code overall is not at all good. You need to look at all the duplicated effort and look at using structs, arrays or vectors to manage the information. The data should be stored in a file and not hard-coded.

http://www.cplusplus.com/doc/tutorial/control/
Last edited on
okay thanks...

then??
closed account (48T7M4Gy)
then??
now all the provinces work except for the second and third province
I'm sorry

i doubled checked not all of the provinces work
how can i fix it??

if the provinces only has 1 word... the program will work... but if it is more than one word... it doesn't display anything
please help... the deadline of my assignment is only at 11:59 pm
i don't want to do that... i just want to fix the minor errors of my program...
kemort actually helps a lot earlier...

the expected program output is when i type the name of the provinces it will show the information of that particular province...

now the problem is when i type a province that has more than one word like "Agusan Del Sur" nothing happens... it's just blank...
i mean it runs but it doesn't display anything...
closed account (48T7M4Gy)
Did you use the getline() advice you got from the other thread you opened?

Looks like you picked the wrong one to close off! :(
i dont know how to do it... :(

as i have said I am new to programming... like... very new...
You can use getline() for the inputs that require a space.
Last edited on
how can i use the getline() ???

where do i put it???
so getline() is a function that reads the white space of your input. You would use getline(cin, input); . You can also take out the else at the very bottom because it's not needed.
Pages: 12