CSE/ENGR 142 Homework 1      (Beach Trip)

Detailed Instructions

 Due: web submission by Friday, July 2 at 5:00 p.m. sharp, paper receipt submission by 10:00 p.m.


Since summer has started, you and your friends have decided to hop in the car for a road trip to the beach! Because you have just learned some C, you offer to help organize the beach trip by writing a program that will help determine both the costs of the trip as well as what type of beach gear you will need to bring along or buy.


Overview

In this homework, you'll take what you've learned about variables, assignments, and expressions, and write your first program from scratch. You'll have plenty of help along the way, including a sample executable you can run to see how the finished product should run. Read all of the information on this page before starting. Pay particular attention to the specifications below, and when you think you're done, make sure to double-check them before you submit your code.
 

Program Specifications

Your program should take the following as input:

Assume that up to 5 people can fit in a car. Also, since everyone will shop at the 142 Beach Store, each volleyball costs $17.75 and sunglasses cost $6.25 each. Volleyball games require groups of exactly 4 players. On this beach trip, volleyball is very popular and everyone wants to play. But since it takes 4 people to play volleyball, there may be 1 or 2 or 3 people who aren't in a volleyball group and these people can go swimming instead.

 Your program should output the following:

Sample Executable

Download and run the sample PC executable hw1.exe and run it several times with different inputs until you get the general idea of what you're going to be writing. One technique for running it is to double-click on it from Windows Explorer.

To make sure you understand the calculations, work some simple cases by hand (or with a pocket calculator or spreadsheet) and see if they match the sample program.

If you play with the sample executable very long, you'll notice that it doesn't handle errors very well. For example, inputting a negative number for the number of people going on the beach trip doesn't make much sense.  Don't worry about these problems for now. Later in the course, you'll see how you could detect and handle these errors, but for this assignment you should just assume that the user will supply only valid and sensible input.

Don't forget to check out the announcements page which contains hints, tips, and corrections!

Output from a few sample runs is provided here, on a samples page.

Getting Started

It would be possible to type in your program from scratch. In that case, you would unfortunately have to go through some additional steps to create a project and a workspace.  To make it easier, just modify hw1.c, the source file provided in the self-extracting archive (get the version 6 archive if you are using MSVC 6.0, or the version 5 archive if using MSVC 5.x).  Just as in the last homework, download the archive to a floppy disk. Once you have extracted the files, run MSVC from the Start menu and open the file hw1.dsw using the File menu's Open Workspace... option. Use the MSVC editor to modify hw1.c. Be sure to re-save hw1.c on your floppy, because you will need it later.   You can also get the file hw1.c by itself but in this case you will have to build a project and a workspace to compile it in.

Once you've added some code to your program, you may find that it doesn't compile right away. Each of these compilation or "syntax" errors has to be solved. Notice that if you click on the error message, you will be placed in the editing window at a point near where the error was detected (often the actual error is a little earlier). Each time you make a change to the program, don't forget to recompile it before executing again.

You will find that the best way to proceed is not to type in the entire program at once and then try to compile. A better way would be to break the problem up into smaller parts, getting each part to build and work properly before moving on to the next.

IMPORTANT NOTE: This work must be entirely your own. If you are in doubt about what is and is not acceptable, please re-read the relevant section from the syllabus .
 

Submitting Your Work

Just as in Homework 0b, you will be submitting your C file via the web and submitting your receipt on paper.

After you're finished testing your program and rereading the instructions, go to the turn-in page to submit your C file. Fill out the form (click on the links labelled "help" if you don't understand something). At the bottom of the form, you will need to specify the name of your file, which is probably named something like A:\hw1.c, but you can use the Browse button to find it if you like. Click the turn in button at the bottom when you're done. Your program will be checked to be sure that it compiles. If all is well, you'll get a receipt back showing what we receieved it. Print out and hand in this receipt at the CSE 142 Homework Turn-In Box. You won't get credit for the assignment if you don't turn in this receipt.

You may turn in the program as many times as you wish.  Only the last version is graded, and only the receipt from this last version should be handed in.


Back to main Homework 1 page...