CS 107 - Summer 2015

Lab Assignment 6

Due: Friday 7/24/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

For this lab assignment, you are to write a C++ program that will print out some information about a set of weather data. The weather data will come from a file named weatherdata.txt. An example of this file is given below. Note we can change around the contents of the file so be sure to write your program to read in the file and calculate the proper results. You may assume that the data file will contain no more than 400 lines of data (but it may certainly contain less).

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 program is to create six arrays to store the information in from the file. Each array will never need to store more than 400 values. Two of the arrays will contain strings, while four of the arrays will contain integers.

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 arrays.

You are to compute and print out the following information from the arrays. Each of these operations MUST be done in its own function.

1. Print out the average high and low temperatures for all of the cities listed
2. Print out the name of the city 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 high temperature and the forecast days high temperature. Also print out the degree difference between the high temperatures for each city.
5. For all cities that have a "SUNNY" forecast, print out the city names who have less than a 20 degree difference between the forecast high and the forecase low temperatures. Also print out the degree difference for each city.
6. For all cities that have a "TSTRMS" or a "SHWRS" forecast, print out the city names who have more than a 10 degree difference between the current days low temperature and the forecast low temperature. Also, print out the degree difference for each city

So main( ) will first define all 6 arrays, then call the function to read in the data from the file, then it will call each of the functions to print out the information.

Submission of the Lab

The lab must be submitted electronically to the Assignment Link for Lab 6 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 6, if you NET-ID was ptroy4, your program should be named: ptroy4Lab6.cpp

-- Main.troy - 2015-07-21

Topic attachments
I Attachment Action Size Date Who Comment
Texttxt weatherdata.txt manage 7.0 K 2015-07-22 - 16:14 UnknownUser  
Topic revision: r2 - 2015-07-22 - 16:14:33 - 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