COSC 071: Computer Science I

Project 1: Chappy's Sail Sale Calculator
Fall 2001

Specific solution and algorithm (written) due: in class, first lecture, week of Sep 24
C++ Implementation (electronic) due: Oct 2 @ 4 PM
5 points

You decide to take some sailing lessons in an attempt to break up the time you spend hacking C++ code for 071. In a conversation with the proprietor, Chappy, you reveal that you're a programmer. Chappy, whose real job is as a sailmaker, instantly enlists you to write a program that produces a list of materials and calculates the cost of making his sails. He also offers to give you a 50% discount on your sailing lessons in exchange for the software, so you agree. To help you with the terminology, Chappy gives you the following diagram:

Fortunately for you, Chappy is old, so he's winnowed down his business to making one type of sail with one type of material. He only makes mainsails and constructs them only from Dacron. Customers must tell Chappy the the length of the luff, the length of the foot, and the length of the roach. Customers must also indicate whether they want reefing points, which sailors use to shorten the sail in heavy weather.

Dacron sailcloth typically costs about $7.90 per yard, for a 36" wide bolt, but this price often fluctuates, depending on where Chappy buys it, so it should be entered for each order. In spite of doing business with cloth manufacturers for many years, he must buy sailcloth in whole yard increments.

Chappy breaks down the cost of labor into two terms. He charges $1.25 for each square yard of sailcloth he has to sew, and he charges $2.50 per foot for the mounting hardware and labor along the foot and luff. This includes grommets, slides, and tracks required to attach the sail to the boom and mast. Chappy spaces reefing points two feet apart, and charges $0.30 for materials and installation of each. Sales tax is 6.5%.

The written portion of this assignment consists of two parts. First, solve the problem using the first data set below. Second, based on this solution, develop an algorithm, the general solution, using the four basic operations INPUT, CALCULATE, DECISION, and OUTPUT, as in homeworks 1 and 2. If you prefer, you may express your algorithm as a flowchart.

Naturally, the implementation portion of the assignment involves writing your algorithm as a C++ program. Make sure it works for the three data sets below.

Avoid using literals in your program by declaring constants for values that do not change during program execution, like for the tax rate. Declare all constants and variables at the top of the main function. Store quantities using the appropriate data type, and if needed, convert between ints and doubles using either static casting.

Data Set Luff Foot Roach Reefs Dacron
1 380 160 8 2 7.75
2 600 198 14 2 8.02
3 240 180 0 0 7.50

A sample run appears below with the user's input in bold:

gusun% a.out

Chappy's Sail Sale Calculator

Enter the length of the luff (inches): 432
Enter the length of the foot (inches): 180
Enter the length of the roach (inches): 12
Enter the number of reefing points (0-2): 1
Enter the cost of Dacron sailcloth: 7.50

Materials Needed:

  Yards of Dacron sailcloth:  35
  Sets of mounting hardware:  51
   Sets of reefing hardware:   6

Costs:

  Dacron sailcloth: $  262.50
  Sewing: $   42.92
  Mounting hardware and labor: $  127.50
  Reefing hardware and labor: $    1.80

     Subtotal: $  434.72
          Tax: $   28.26
   Total Cost: $  462.97

gusun%

Instructions for Electronic Submission: At the top of the file containing your source code (i.e., the file containing the C++ instructions), place the following header comment, with the appropriate modifications:

//
// Project 1
// Name: <your name>
// E-mail: <e-mail address>
// Instructor: Maloof | Shields
// TA: <TA's name>
// COSC 071-<section number>
// Platform: Solaris (gusun) | Linux | Windows | Macintosh
// Compiler: g++ | Visual C++ | CodeWarrior | Borland  etc.
//
// Description: <Describe your program>
//

Although you may use any C++ compiler to develop your program, it must run under UNIX and must compile using GNU g++. When you are ready to submit your program for grading, if necessary, use ws-FTP to transfer your file from your PC to gusun. Use SSH to logon to gusun, and use pine to e-mail it to your TA with your netid and the suffix ``.cc'' as the subject. To run pine, type at the UNIX prompt:

gusun% pine

When the menu appears, select the item for composing e-mail. Assume that your netid is ab123, the name of your source file is proj1.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., proj1.cpp), which it will then load as your message text. At this point, your screen should look something like the following:

Finally, type ^X to send the e-mail to your TA.

IMPORTANT: Do not send your source code as an attachment. Do not use a mail client other than pine.

If you need to include a message to you TA about your submission, then type the message as a comment in the program.

Once you've submitted your project, it is important to keep an electronic copy on a university machine (e.g., gusun or cssun) that preserves the modification date and time. If we lose your project or the e-mail system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.

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.