Homework 2
Spring 2002
Written due in lecture, Tue, Feb 5th
E-mail due: Feb 1 @ 5 PM
5 points
This homework is designed to get you familiar with algorithms and with entering, compiling, and submitting C++ programs using either Visual C++ (Windows), CodeWarrior (Windows), or GNU g++ (UNIX).
For example, if we had a triangle pizza, we may write something like:
The advantage of doing this is that we've separated the procedure for calculating the price per square inch of a pizza from any set of specific numbers. To compute a new price per square inch, we simply reassign the variables that correspond to the cost and the size of the pizza, and apply the algorithm.
For our triangle pizza example, we may write something like:
Express your algorithm for deciding which pizza is the better buy in terms of these statements.
You can find CodeWarrior and Visual C++ on the UIS Windows machines that litter campus. We'll be submitting all projects this semester via e-mail using pine on the gusun system, so if you plan on using CodeWarrior or some other Windows or Mac C++ compiler, then you'll need to use DOS ftp or ws-FTP to transfer your source code from a Windows machine to gusun. There is a transcript of a DOS ftp session on the COSC-071 FAQ page. Also see: HOWTO transfer files to gusun with ws-FTP, HOWTO compile using Visual C++, and HOWTO compile using CodeWarrior
You can find the GNU g++ compiler on gusun, a UNIX machine. Use a telnet program to connect to these machines from the Internet or from a Windows machine on the campus network. Also see: HOWTO compile using g++
Note that students in previous classes had trouble with Microsoft's telnet client. Plus, it isn't secure, so I'd recommend using a secure telnet client, like SSH. There's also NetTerm, which isn't secure.
The editors on gusun are named ``vi'', which is a full-screen editor, and ``pico'', which is also a full-screen editor. The documentation for these editors is available on-line. For vi, type at the UNIX prompt ``man vi'' for UNIX's on-line manual pages. There are also several links to Web pages from the class's main page. Note that vedit is a version of vi that is intended for beginners. For pico, once inside the editor, you can type Control-G to get help. If you plan to use UNIX this semester, I'd highly recommend learning to use vi. pico is simple, but it is also simplistic, especially for editing C++ code.
Note: For problem 2.8, remove both include statements.
If you plan to use CodeWarrior or Visual C++ this semester, then you first must use ftp to transfer your source file from a Windows machine to gusun. A transcript of an ftp session appears on the COSC071 FAQ page. You can also use ws-FTP, which is a GUI version of ftp. See HOWTO transfer files to gusun with ws-FTP, HOWTO compile using Visual C++,
Once you use ftp to put your source file on gusun, use a telnet client to log in. This semester, you'll be submitting projects via e-mail using pine. Do not use another e-mail client. To run pine, type at the UNIX prompt:
gusun% pine
When the menu appears, select the menu item for composing e-mail. Assume that your netid is ab123, the name of your source file is prog211.cpp, and your TA's e-mail address is ``imagoodtamaloof@cs''.
Type your TA's e-mail address in the To field, and type your netid with the .cc suffix in the Subject field (no spaces before or after). Move the cursor down into the MESSAGE TEXT screen, and type the ^R command. Pine will ask for a file name (e.g., proj211.cc), which it will then load as your message text. At this point, your screen should look something like the following (for the information above):
Finally, type ^X to send the e-mail to your TA.
The TAs who will be grading your projects this semester are listed on the main page. You must e-mail your project before 4:00 PM on the due date.