-
compairing rates
I am currently writing a program for a class in which you open two files and after getting the info you calculate the divorce rate for 97,98,99 for severaly counties. Once you do that you have to compare the divorce rates and get the three highest and the three lowest. My question is how would I set it up to compare the rates and print out the three highest with the three lowest.
-
use a pencil and paper to write out how you are going to read in the data. Presumably you will be given information such as county name, count population, and number of divorces in count for each given year. Use the information directly from file if you think you can handle that, or store it in container of some sort. Either way, calculate divorce rates by county by year, if it's not already available in that format. For each year compare each counties rate by the previous high and low rate. If the current county is higher or lower than the current high or low replace the current high/low by the current. Once you have done a given year, or after evaluating all three years, print out the pertinent part of the report.
If you are familiar with struct/classes they may be useful to you. If you are familiar with multi-dimensional arrays they could be used if you wish. You could also use several different "linked" arrays (element 0 always refers to a given county, element b to another, etc).
Once you have it all figured out on paper, then try writing up some code.