/***************************************************
Analyzing Census data: Town/City/ADP Count
Write a program that reads in the Maryland data file
from:
www.census.gov/population/www/censusdata/places.html
and prints out the number of towns, cities, and
CDP's. Note: You'll have to save the data file to
your machine first!
***************************************************/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
// Open input file
ifstream fin("24md.txt");
// Initialize town count
int count_t, count_c, count_cdp;
count_t = count_c = count_cdp = 0;
// Read in string until file is finished
string s;
while(fin >> s)
{
if (s == "town")
count_t++;
else if (s == "city")
count_c++;
else if (s == "CDP")
count_cdp++;
}
// Write results
cout << "There are " << count_t
<< " towns in Maryland" << endl;
cout << "There are " << count_c
<< " cities in Maryland" << endl;
cout << "There are " << count_cdp
<< " CDP's in Maryland" << endl;
return 0;
}