CS 102 Assignment #3

Due: Feb 9

Vassar Boatworks (VB) builds custom boats for rich folks. Customers can order a boat by specifying the length, width, horsepower, and number of sleeping berths they'd like. Calculating the cost of a custom boat has gotten to be a chore, and VB has offered you a great deal of money to write a program to calculate it for them. You code must also verify that the customer's specifications will result in a seaworthy boat!

VB can build boats from 15 to 75 feet in length, in increments of one foot. The width can be from 5 to 25 feet in increments of one foot. Customers can request 0 to 14 sleeping berths on board, and engines with 10, 50, 100, 500, or 1000 horsepower can be specified. Your program should ask for all of these input values, then report on any that are out of range.

Even if the limits are within range, VB needs to make sure that the specified boat satisfies some basic constraints (you don't want a boat to be wider than it is long, for example). The length of the boat must be three or more times, but not more than five times, the width. The number of sleeping berths cannot exceed 1/100 of the product of the length and width. Finally, the horsepower can be no greater than 0.6 times the product of the length and width. Whether or not the user's inputs are within range, your program should tell the user about any violated design constraints.

If all of the inputs are valid and no design constraints are violated, your program should print the cost of the boat, specified as follows: $25 times the square of the length, plus $150 for each sleeping berth, plus $8 for each horsepower. (Print the cost with two digits after the decimal point.) Otherwise, ask the user for a revised set of input values and try again. Your program should repeat this process until a valid design has been specified.

Here is a sample run:

mote33[52] : a.out
Vassar Boatworks Pricing Software

Enter length of desired boat (15-75 feet):    80
Enter width of desired boat (5-25 feet):      4
Enter number of sleeping berths (0-14):       15
Enter engine horsepower (10,50,100,500,1000): 750

Verifying that inputs are valid...
        You specified an invalid length.
        You specified an invalid width.
        You specified an invalid # of sleeping berths.
        Horsepower choice not available.
Verifying design constraints...
        Boat is too narrow for its length.
        Boat is overpowered.
        Can't fit 15 beds on specified boat

Please try again...

Vassar Boatworks Pricing Software

Enter length of desired boat (15-75 feet):    50
Enter width of desired boat (5-25 feet):      10
Enter number of sleeping berths (0-14):       3
Enter engine horsepower (10,50,100,500,1000): 50

Verifying that inputs are valid...
Verifying design constraints...

Your design is valid.
The specified boat will cost $63350.00

Thank you for choosing Vassar Boatworks

During grading, particular attention will be paid to:

You will submit your assignment via the submit102 program.