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