Question: For my programming class, we have to do the following, however, I've not been able to come up with a way to code this practice

For my programming class, we have to do the following, however, I've not been able to come up with a way to code this practice set by only using loops and IF statements. Any help would be appreciated!

Write a C++ program that will read in a file of states and populations. When the program has read through the complete file, it will display the following information:

  • the city and population with the smallest population
  • the city and population with the largest population
  • the city name and population that would appear first in an ascending list
  • the city name and population that would appear last in an ascending list
  • the number of states listed in the input file
  • the average population of the states listed in the input file

The input file is named StateDemographics.txt and is located in the current directory. The input file consists of the name of the state on one line and its respective population on the next line. Do not store all the information from the input file. Only store the information listed above

StateDemographics.txt

Colorado 5842076

Oregon 4283747

Texas 27469114

New Jersey 8791894

Wisconsin 5686986

New Hampshire 1359711

Virginia 8626210

Missour i5988927

Georgia 3989167

Vermont 600412

South Dakota 899174

Washington 7656200

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!