help with project 2

In this project we are going to be expanding the into the rest of the ways to structure our programs. We will be focusing on loops and functions in addition to selection statements. So you’ll be required to use loops and functions in this project.

Details
For this project we’ll be reading in a delimited file. The file will be information about a countries around the globe. Then we’ll be processing a series of commands about the file. On each command you’ll be reading the file that was given by the command file. You won’t be storing the file information in any sort of structure between commands, i.e. no using arrays, vectors, lists, etc.

Commands
There will be 3 commands we will be dealing with. One of the commands will have 3 versions, so we’ll have a total of 5 commands if you want to count them that way.

The command file will start with a line that has the word Data File: and then a file name. That file name is the name of the data file you’ll be using for the commands to do its searching. You are not to read and store that information in any sort of array, list, vector, etc.

size - the size command will have one of 3 subcommands after it.
average - if the word average comes after the size command, then you'll calculate the average size of the countries that are included in the input file.
smallest - if the word smallest comes after the size command, then you'll find and display the smallest of the countries that are included in the input file.
largest - if the word largest comes after the size command, then you'll find and display the largest of the countries that are included in the input file.

country - the country command will be followed by a string that could represent a country code from the file. You'll search through the input file and if you find the given country code, then you'll display the information about that country.

neighbors - the neighbors command will be followed by a string that could represent a country code from the file. You'll search through the input file and if you find the given country code in the neighbors list for a country that's included in the input, then you'll display the information about that country.
Each of the commands has the possibility for nothing to be found and displayed. So there will be responses for those. Look lower to see what to do in those case.

Here’s a sample of what the input could for the commands could look like

Data File: countryInfo.txt
size average
size largest
size smallest
country US
neighbors US
country NONE
neighbors WHO
So this shows all of the possible commands including some that should probably produce negative results for not finding a country or a neighbor.

It is possible that the command file and/or the data file are empty.
The data file may potentially contain any number of lines at the top that are comments. Comments are indicated by any line that starts with a #. Any line that starts with a # should be ignore and are not considered part of the input data, even if that line would normally be a country data record.

The records are made up of several fields, any of which could be blank. They are

ISO
ISO3
ISO-Numeric
fips
Country
Capital
Area(in sq km) - this should be a double not an int
Population
Continent
tld
CurrencyCode
CurrencyName
Phone
Postal Code Format
Postal Code Regex
Languages
geonameid
neighbors
EquivalentFipsCode
Yes, that’s a lot of fields, and yes I want you to read them all.

Description of some of the fields:

ISO - that’s the country’s ISO abbreviation. It’s two letters long. It’s what we are using when we are searching for a country. For example, the United States would be US not USA.
Area(in sq km) - that’s the area of the country in square kilometers. We’ll be using this to calculate average, smallest and largest countries.
neighbors - this is a comma separated list of ISO country codes. For example, the US’s neighbor list is: CA,MX,CU. I’ll leave it to you to figure out what countries those are. (Hint: this program would find those countries if you do it correctly.)
The rest of the data is just coming along for the ride. When we display a country, we will display the entire record, e.g. every field, all 19, even if it is blank.

I’ll be posting the complete countryInfo.txt and some samples for you to use. Some of the samples will have some of the countries commented out. Your program should treat those countries as not being in the file and they are not searched.
I have written a code. I need to know if my logic is correct.
Topic archived. No new replies allowed.