Purpose : write a program to record temperatures in several cities with the aid of files.
The goal of this project is to develop an interactive program that allows to maintain temperatures in several cities. The city names and temperatures are stored in a file. If the name of the executable is logtemp, then a sample session goes like :
[jan@obelix Project5]$ ./logtemp temp
Give name of city (enter to stop) : Brussels
Give the current temperature in Brussels : 45.5
Give name of city (enter to stop) : New York
Give the current temperature in New York : 65
Give name of city (enter to stop) : Chicago
Give the current temperature in Chicago : 53
Give name of city (enter to stop) : Los Angeles
Give the current temperature in Los Angeles : 66.2
Give name of city (enter to stop) : Chicago
The current temperature in Chicago is 53.0
Give the new current temperature in Chicago : 48.2
Give name of city (enter to stop) : New York
The current temperature in New York is 65.0
Give the new current temperature in New York : 32.4
Give name of city (enter to stop) :
[jan@obelix Project5]$
After this session, the file temp looks like
Brussels 45.5
New York 32.4
Chicago 48.2
Los Angeles 66.2
Note that some city names contain spaces.
You may assume that city names have no more than 80 characters.
Temperatures are stored as floating point numbers in fields of
width 8 and precision one.
When we relaunch the program, we can add new cities and update the
temperatures :
[jan@obelix Project5]$ ./logtemp temp
Give name of city (enter to stop) : Denver
Give the current temperature in Denver : 89
Give name of city (enter to stop) : New York
The current temperature in New York is 32.4
Give the new current temperature in New York : 45.3
Give name of city (enter to stop) :
[jan@obelix Project5]$
If the file does not exist already when the program is launched,
then the program must create the file, otherwise new lines are
appended for cities not currently listed, or the current temperature
of already recorded cities can be updated.
After the above session, the content of the file temp is
Brussels 45.5
New York 45.3
Chicago 48.2
Los Angeles 66.2
Denver 89.0
Mind spelling mistakes in the dialogue with the user.
If the user does not provide a file name, then your program
should behave as follows :
[jan@obelix Project5]$ ./logtemp
Need one file as argument. Please try again...
[jan@obelix Project5]$
The listings of your program will be collected at the start of the lecture on Friday 27 April, at 1PM. Also send the code by e-mail to jan@math.uic.edu. The first line of your program should be like
/* MCS 275 Project Five by <Author> */
where you replace the < Author > by your name.
Write appropriate documentation inside the code to comment on your subroutines. The gcc compiler will be used to test your program. So even if you have developed your program in a Windows environment, it may be good to run your final version on icarus.cc.uic.edu where the gcc compiler is installed. A final note to Windows users: with the Cygwin tools you can use the gnu tools from Windows.
If you have questions, comments, or difficulties, feel free to come to my office for help.
Mark your calendar for the following event :
FINAL EXAM in LC C3 on Monday 30 April 2001 at 1:00-3:00PM.