CS 107 - Summer 2015

Lab Assignment 7

Due: Friday 7/31/15 at 11:59pm

Write a C++ Program (using only the C+ subset as defined in lecture) that will:

  1. Print out your name
  2. Print out your net-id
  3. Print out CS 107 and Semester information (Summer 2015)
  4. Print our the Assignment Name and Number (Lab Assignment 3)
  5. Print out your lab time (Wednesday at 10am)
  6. Print out the additional information as described below:
Weather Data Analyzer REDO

This assignment will be very similar to Lab Assignment 6, except you need to create a C/C++ struct to contain the 6 values for each city (name, high, low, forecast, forecased-high and forecasted-low). So the weather information will be stored in an array of structs rather than 6 different arrays.

You will also need to create the array as a dynamic array. Initially, the array may contain spaces for 10 cities. As you are reading in the data, the amount of data able to be stored should double everytime the array gets full.

Since we don't know the size of the file or which file will contain the information. Your program should first prompt the user for the name of the file to read the data. Below are three sample data files:

This data file contains information in the following format
ALLENTOWN 90 72 PTCLDY 89 61
AMARILLO 88 65 TSTRMS 87 67
ANCHORAGE 74 58 PTCLDY 68 54
ASHEVILLE 89 68 MOCLDY 87 67
ATLANTA 93 77 PTCLDY 93 75
The file contains the following information:
  • The first column of data contains the name of a city. The city name is no more than 15 characters long.
  • The second column of data contains an integer showing the current days high temperature.
  • The third column contains an integer showing the current days low temperature.
  • The fourth column shows the weather forecast for the next day.
  • The fifth column contains an integer showing the next day's forecasted high temperature.
  • The last column contains an integer showing the next day's forecasted low temperature.
You are to first write a function that will open up the data file, read in the information until the end of the file is reached and store the data read on each line into the array.

You are to compute and print out the following information from the array. Each of these operations MUST be done in its own function. Note some of the below operations are the same as Lab Assignment 6, but some are not the same.

1. Print out the average high and low temperatures for all of the cities listed
2. Print out the name of the city (or cities) with the highest high temperature.
3. Print out the names of the cities with a low temperature that is less than the average low temperature.
4. Print out all cities that have a 10 degree or more difference between the current days low temperature and the forecast days low temperature. Also print out the degree difference between the low temperatures for each city.
5. For all cities that have a "TSTRMS" or a "SHWRS" forecast, print out the city names who have a forecast high temperature that is higher than the current days average high temperature for all cities.
6. For all cities that have a "SUNNY" forecast, print out the average forecast high temperature and the average forecast low temperature.

Submission of the Lab

The lab must be submitted electronically to the Assignment Link for Lab 7 inside of Blackboard. You will only need to submit the C++ source code file (just the ".cpp" file, not the "a.out" file).

You are to name your program file using both your NET-ID and the Lab Number. Thus for Lab 7, if you NET-ID was ptroy4, your program should be named: ptroy4Lab7.cpp

-- Main.troy - 2015-07-28

Topic attachments
I Attachment Action Size Date Who Comment
Texttxt weatherdata.txt manage 7.0 K 2015-07-28 - 20:54 UnknownUser  
Texttxt weatherdata2.txt manage 0.5 K 2015-07-28 - 20:54 UnknownUser  
Texttxt weatherdata3.txt manage 3.9 K 2015-07-28 - 20:54 UnknownUser  
Topic revision: r1 - 2015-07-28 - 21:04:01 - Main.troy
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF