Matt Mahoney
Fall 2008
http://cs.fit.edu/~mmahoney/cse1502/
Tentative - subject to change prior to start of classes.
Aug 18 through Dec. 3, 2008 on Mon., Wed., and Fri. Olin room EC 127-128 (combined rooms). No classes on Sept. 1, Oct. 13-14, Nov. 11, Nov. 26-28. There are 3 or 4 sections at different times, each with a different instructor. The following schedule will probably change:
It is possible that the 3PM section will be cancelled, in which case I may teach the 1PM or 2PM section.
Help Desk Schedule in room EC272 (as of Oct. 17, 2008).
Each instructor will have their own syllabus, homework assignments, exams, and grading policy. This syllabus applies only to Matt Mahoney's section.
Engineering Problem Solving with C++ 2nd Ed. by Delores M. Etter and Jeanine A. Ingber, Pearson/Prentice Hall. ISBN 978-0-13-602071-4. (All sections will use this book). Also read the tutorial and Introduction to C++.
All students are expected to join the CSE 1502 mailing list. You are responsible for material posted to this list by instructors. You are also encouraged to post questions or answers about your homework or about C++ in general here, because other students might have the same questions.
To post a message, send email to cse1502@lists.fit.edu. When replying to a post, remember to check the "to" address before sending, depending on whether you want to reply to the sender or the whole class. Please do not post your homework to the list.
Fall 2006 exams
Exam 3
Final exam
Spring 2007 exams
Exam 1
Exam 2
Exam 3
Final
Fall 2007 exams
Exam 1
Exam 2
Exam 3
Final
Spring 2008 exams
Exam 1
Exam 2
Exam 3
Final
Homework assignments will be programming assignments graded manually for correct design, function, documentation, and neatness. Partial credit is given based on my subjective opinion of how well you understand and describe the problem in comments (the specification), your approach (design), and testing (whether it works or gives appropriate error messages for unusual or unexpected inputs). Grading depends on human readability as well as machine readability. Code should be indented using the style in the book. Major sections should be commented. Variable names should be self documenting or their purpose should be commented as appropriate. Your homework should include your name and email address in the comments.
Homework must be submitted by email by midnight of the due date. Late assignments are penalized 20% per day. I encourage you to submit homework early for me to comment on, and submit revised versions later without penalty. I will grade only the best version.
You must cite all sources of outside help in your comments, including help received from other students or the Internet. Copying code or allowing your code to be copied is not allowed. Group assignments are not allowed. You are expected to know the CS department policy on academic honesty. Penalties for cheating can range from a zero on the assignment to expulsion from the university. I report incidents of cheating to the department head.
Final grade = (average of top 3 exams)/2 +
(total of homework grades)/2.
90-100=A, 80-89=B, 70-79=C, 60-69=D, 0-59=F.
Fall 2006 syllabus
Spring 2007 syllabus
Fall 2007 syllabus
Spring 2008 syllabus
You will need a C++ compiler for your home computer. You may use any standard ANSI C++ (released since 1999) compiler under any operating system (Windows, UNIX, Linux, Mac). I recommend (but don't require) MinGW g++ for Windows or GNU g++ for other operating systems. All of the following are free under Windows:
MinGW g++. This runs from a command window only. Download and run the installer (MinGW_Toolbox_Setup.exe, 23 MB). Add C:\mingw\bin to your PATH. In Vista, you may also have to copy the file cc1plus.exe from c:\mingw\libexec\gcc\mingw32\3.4.5 to c:\mingw\bin.
Visual Studio 2005 Pro or Standard. You will need a TRACKS account and be registered for this class to download it. This has a GUI and lots of features. The Pro version download is 2.8 GB (DVD image). Not recommended for older machines or slower connections. To install, download the 4 .rar files, unrar e *.rar, then burn a DVD from the .iso file or use the provided program to mount the .iso to disk and run vs\autorun.exe as administrator.
Borland C++ 5.5. This runs from a command window only. Works on old machines. Click on "compiler", register, and download the installer (8.7 MB). After installing, add C:\Borland\BCC55\bin to your PATH and create the file C:\Borland\BCC55\bcc32.cfg exactly as shown below:
-I"c:\Borland\Bcc55\include" -L"c:\Borland\Bcc55\lib"
Digital Mars C++ Compiler 8.49. This runs from a command window only. Works on old machines. Unzip stlport.zip (2 MB) and dm849c.zip (3 MB) in C:\ to install in C:\dm and add C:\dm\bin to your PATH.
Be sure to test your compiler by writing a simple program, compiling, and running it, e.g.
// Paste this file into notepad and save as hello.cpp // To compile from a command window: // MinGW: g++ -Wall hello.cpp -o hello.exe // Borland: bcc32 hello.cpp // Mars: dmc hello.cpp -IC:\dm\stlport\stlport // To run: hello // // In Visual Studio: create new project, select Win32 console application, // uncheck "precompiled headers", delete the supplied code, replace with this code // and click Build project, Debug/Start debugging. // #include <iostream> using namespace std; int main() { cout << "Hello world\n"; return 0; }
Due Wed. Sept. 3, midnight, 10 points. A projectile is fired at initial velocity v and angle theta from horizontal. You will write a program that inputs v (in meters per second) and theta (in degrees) and outputs the distance in both feet and meters to where the projectile lands. See figure below. Assume the surface is horizontal, that the acceleration of gravity is 9.8 m/s2, and neglect the effects of air resistance.
Be sure your program prompts the user to enter the two values. For example (user input shown in bold):
Enter initial velocity in meters per second: 25.7 Enter elevation angle (0 to 90 degrees): 64.5 The projectile travels 52.3773 meters, or 171.841 feet.
The input and output does not have to be formatted exactly as shown, but should give the correct answers. Your program should include a specification (what are the inputs and outputs?) and your name in the comments. Email the source code file (.cpp file) to me as an attachment.
Due Fri. Sept. 19, midnight (15 points). Write a program to score arithmetic tests. Your program will read arithmetic equations and output whether or not they are correct. If not, provide the correct answer. When finished, print the number correct, total number of equations, and the numeric grade (out of 100). Each equation will be on a line by itself and have the form:
number operator number = numberwhere number is an integer like 87 or -2 (no decimal point), operator is one of +, -, *, or /, and there are single spaces between each of the 5 tokens. The program should read until end of file or until it encounters any invalid input. For example, if the input is:
3 + 2 = 5 100 / -7 = -14 8 - 2 = 5 4 * 1000 = 4000 2.0 = 73 - seventy one (invalid input, stop here) 2 + 2 = 4Then the output should be:
3 + 2 = 5 is correct. 100 / -7 = -14 is correct. 8 - 2 = 5 is wrong. The answer is 6. 4 * 1000 = 4000 is correct. 3 out of 4 were correct (75%).
You can test your program by copying the above input into a text file and running your program with the input redirected to that file.
The following input is invalid: characters other than digits or a leading - where a number is expected, characters other than + - * or / where an operator is expected, and anything other than = where = is expected. You do not need to print an error message here. You may simply ignore the input and everything after it. You do not need to prompt for input.
Be sure your specification is complete and understandable to someone who knows nothing about this assignment or your program. Be sure to include your assumptions about how division is computed with regard to rounding and division by 0.
Due Wed. Oct. 1, midnight (15 points). A weather balloon instrument periodically sends temperature and elevation data to a ground station, which records this information in a text file. Each line of the file contains a reading of the form:
hh:mm:ss elevation temperaturewhere the time is in hours, minutes and seconds, and the elevation and temperature are floating point numbers (type double) representing meters and degrees Celsius. The data is ordered by increasing time with at least one second between readings. Times may range from 00:00:00 to 99:59:59.
Your task is to write a program that inputs the name of the data file and a time in the form hh:mm:ss, and reports the elevation and temperature at that time either by finding an exact match, or if there is no match, by finding the closest times before and after and interpolating between them. If you enter a time before the first reading or after the last reading, then it is not possible to interpolate, so your program should print an appropriate error message instead. Also, report an error if the input file does not exist. You may assume that if the file exists, then the data is correctly formatted and contains at least 2 readings.
For example, suppose balloon3.txt contains:
00:03:00 500 16.5 00:04:00 550 17.5 00:04:30 570 17 01:44:30 870 -3Your program should run as in the following examples. User input is shown in bold.
Enter time: 00:04:00 Enter file name: balloon3.txt Elevation is 550 Temperature is 17.5 Enter time: 00:03:30 Enter file name: balloon3.txt Elevation is 525 Temperature is 17 Enter time: 00:04:20 Enter file name: balloon3.txt Elevation is 563.333 Temperature is 17.1667 Enter time: 01:34:30 Enter file name: balloon3.txt Elevation is 840 Temperature is -1 Enter time: 00:02:59 Enter file name: balloon3.txt Error: time is before first reading. Enter time: 01:45:00 Enter file name: balloon3.txt Error: time is after last reading. Enter time: 00:04:00 Enter file name: balloon4.txt Error: file balloon4.txt not found.
Your program should include a function to interpolate between two points. You will need to call it twice: once to interpolate the elevation and again to interpolate the temperature. Be sure that in addition to the usual specification, that you comment the function as to what the input arguments are and what it returns.
Remember that I might test your program with a file named something other than balloon3.txt, and that it might contain some different data.
Due Fri. Oct. 17, midnight (15 points). Write a program to remove comments from C++ programs. Your program should read a C++ file from standard input and write an equivalent C++ file to standard output such that all comments are removed but all other code is intact and the program behavior does not change when compiled and run. You may assume that the input is a valid C++ program that compiles with no errors. Your output should likewise. The rules are as follows:
Due Wed. Nov. 5, midnight (20 points). Write a program to solve word search puzzles. Your program will take 2 file names as command line arguments (not from input). The first file will contain a puzzle as a grid of letters. The second file is a dictionary. The output of your program will be a list of words that can be found in the grid reading either up, down, left, right, or diagonally, 8 directions in all.
The puzzle file contains a number n on the first line followed by an n by n grid of uppercase letters on n lines with a space between each letter. The dictionary file contains a list of words, one per line. The words may be upper or lower case. Your program should treat these as equivalent. A dictionary word might also contain printable characters other than letters, such as apostrophes, digits, or hyphens. Such words will never be found in the puzzle.
For example, suppose puzzle.txt contains:
4 B O Y S T A C S O N T A M Y A MAnd suppose dict.txt contains:
a ant apple boy cat dog girl Sally Sam TomAnd you ran your program a.exe as follows:
a puzzle.txt dict.txtThe output should be:
a ant boy cat Sam TomThere should be no limit on the size of the puzzle or the number or length of words in the dictionary. Be sure to test
a puzzle30.txt wordswith this output, and
a puzzle10.txt english.dicwith this output, and
a puzzle50.txt english.dicwith this output. Additional puzzles: puzzle5.txt, puzzle20.txt.
Your program should give appropriate error messages (not crash) if the user enters the wrong number of command line arguments, or if the input files are not found.
Due Dec. 3, 2008, midnight (25 points). Your program will count words in a text file and calculate some statistics. In particular, your program will take a file name and a list of words on the command line, print the number of times each of these words occurs, the number of types and tokens, the 10 types with the highest counts, the number of types with counts of 1 through 10, and the number of types that are tied for the highest count.
We use "type" and "token" to distinguish the 2 different meanings of the word "word". A type is a word in a dictionary. A token is a word in text. For example "The cat in the hat" has 5 tokens and 4 types because the type "the" occurs twice.
A word is defined to be any sequence of one or more letters (a-z) followed by a non-letter. Upper and lower case are considered equivalent. For example, "The", "the", and "THE", are 3 tokens of the same type. "isn't" is 2 tokens.
The program is partially written. You are supplied two files, f08hw6.h and f08hw6test.cpp. You will write one other file, which you can name any way you like with a .cpp extension, for example, myprogram.cpp. To compile, put all 3 files in the same folder and give the two .cpp files to the compiler, e.g.
g++ myprogram.cpp f08hw6test.cppThis will produce a.exe. The program will run with a file name and a list of words. For example, suppose the file test.txt contains:
This is a test. THIS is another test...Then the command,
a test.txt here is a testwill produce the following output:
test.txt has 5 types and 8 tokens. here occurs 0 times. is occurs 2 times. a occurs 1 times. test occurs 2 times. The most common types and their counts are: 2 is 2 test 2 this 1 a 1 another Count distribution: 2 types occur 1 times. 3 types occur 2 times. test.txt still has 5 types and 8 tokens.Also,
a alice.txt this is a testwill output:
alice.txt has 2576 types and 27331 tokens. this occurs 134 times. is occurs 108 times. a occurs 632 times. test occurs 0 times. The most common types and their counts are: 1642 the 872 and 729 to 632 a 595 it 552 she 545 i 513 of 462 said 411 you Count distribution: 1122 types occur 1 times. 395 types occur 2 times. 228 types occur 3 times. 144 types occur 4 times. 91 types occur 5 times. 63 types occur 6 times. 61 types occur 7 times. 54 types occur 8 times. 34 types occur 9 times. 37 types occur 10 times. 1 types occur 1642 times. alice.txt still has 2576 types and 27331 tokens.
Your program should contain the code for the 8 member functions of class Dict. (The other two are inlined). The requirements for each member function are commented in the header file, f08hw6.h. The test file f08hw6test.cpp give examples of how the functions are used. It already has the function main() so you don't need to write one. These two files should not be modified in any way. Submit only your file. I already have the other two.
Grading: 3 points for each member function correctly implemented (plus 1 free point). You do not need a specification.
Extra credit is due Dec. 3, 2008 by midnight. It will be worth a maximum of 20 points. However, your total homework score cannot exceed 100. If your other 6 assignments total more than 80 points, then it will be graded in proportion to the difference between your total homework grade and 100.
Write a program to compare the words in two files. The program should print the number of types and tokens that appear in each file but not the other, and the number that appear in both files. For example, if file1 contains
This is a test.and file2 contains
This is another test. This is yet another test. This is one more test.then
Your program should #include "f08hw6.h" and create 2 Dict objects from homework #6, one for each file, and use the member functions you wrote to compute the result. Your program should not directly read the files. Submit only one file. I will link it with your code from homework #6 and the above header file. Class Dict (both f08hw6.cpp and the code you submitted for homework #6) must be exactly the same for this program.
I have omitted some key details. Be sure to fill in these details in your specification. Use your judgment. Your program should behave exactly the way your specification describes it, and not surprise the user.