Computer Science 121
Assignment 7
Due: April 5, 1999
 
  1. Create a data file called cities.txt. It should contain the names of the cities New York, Washington DC, Albany, Boston, and Jersey City. Each should be written on a separate line. Write a program to read in these names and display (echo) them on the screen. Use the C++ method getline to read each in.
  2. Next, modify the data file and save it as weather.txt. It should contain the same cities as before now delimited by a comma. Each city's name should be followed by the high and low temperatures for the day. Numbers in the file should be separated by white space. Write a program to read the data in from the file and display it on the screen in even rows and columns. Provide a heading for each column that describes the data in that column.        

            New York, 45 36
            Washington DC, 55 41
            Albany, 42 34
            Boston, 35 28
            Jersey City, 49 41

  3. Last write a program to read in the data and display on the screen the city name followed by the average temperature for that city. For example, the first line would read

           New York        40.5