Fall 2004

Clay Shields


front | classes | research | personal | contact

Project 1 - Puppy food calculator

Assigned: Sept. 22
Design due: Sept 29
Progam source code due: Oct. 6

Puppy Food Purchasing


In order to provide disabled people with service animals, guide dog organizations breed and raise hundreds of puppies a year. For this project, you are going to program a calculator that a guide dog organization can use to order food to feed their puppies. Here is a gratuitous picture of some guide dog puppies to keep you motivated. Don't make them go hungry!

puppies

Puppies get introduced to solid food gradually starting at five weeks of age, and go to homes to be raised when they are nine weeks old. They get three meals a day and are fed a mixture of dry food and canned food. The mixture for each meal varies by age as show in the table below.

Puppies' Age
(in weeks)
Ounces of
Canned Food
Ounces of
Dry Food
5
2
1
6
2
2
7
3
3
8
3
5

Dry dog food comes in large bags weighing 10 pounds. Each bag costs $5.40. Cans of puppy food contain 12 ounces, and cost $1.25. Sales tax on dog food is 4%. Sometimes stores will give a discount to the guide dog organization, though the percentage they give varies.

What you need to do is write a program that takes as input the number of puppies of each age, and if there is a discount and if so how large it is. It then outputs a shopping list of how many cans and bags of puppy food to purchase, as well as the total cost of the food without discount, the cost with the discount applied if applicable, the amount of the tax on it (tax is computed on the discounted total if applicable), and the total cost with tax for the accountants.

A sample run of a program that does this is:

Welcome to the puppy food purchasing program

Please enter the following information:
Number of five week old puppies: 14
Number of six week old puppies: 19
Number of seven week old puppies: 12
Number of eight week old puppies: 9
Did you get a discount? (y/n): y
Enter percent of discount (example: .1 = 10%): .2

This week we need:
Cans of food: 226
Bags of food: 18

Cost of food: 379.70
Discounted cost of food: 303.76
Tax amount: 12.15
Total cost: 315.91

What to submit

Part 1 - Design Document

For the first part you are to submit a design document showing the algorithm you plan to implement. You may submit the algorithm as a flowchart, or may write it out neatly using a language which is similar to that from Homework 1 and has the following terms:
  1. input
  2. output
  3. calculate
  4. if condition, then statement
  5. if condition, then statement; otherwise, statement
  6. start
  7. stop
If you need to group multiple statements together, say in an if statement, use
    begin
       statement
       ...
       statement
    end
A copy of your algorithm is due in class. Be sure to keep a copy for yourself!

Part 2 - Program Source Code

Important: Your output and input should be very similar to that shown in the example program. Please ask for the input in exactly the same order shown (you will not ask for the discount rate if no discount is given), and only request the same items shown - do not ask for any other input. This will assist in grading your program.

Include the following header in your source code.

//
// Project 1
// Name: <your name>
// E-mail: <your e-mail address>
// COSC 071
//
// In accordance with the class policies and Georgetown's Honor Code,
// I certify that I have neither given nor received any assistance
// on this project with the exceptions of the lecture notes and those
// items noted below.
//
// Description: <Describe your program>
//

You will submit your source code using the submit program. Do not submit the compiled version! I don't speak binary very well.

To submit your program, make sure there is a copy of the source code on your account on gusun. You may name your program what you like - let's assume that it is called puppies.cc. To submit your program electronically, use the submit program like we did in Homework 2, but with the command:

submit -a p1 -f puppies.cc

I will not be enabling the electronic submission until after the design documents are in, so don't try to submit too early.

Update

I realized I didn't make clear what happens when there is no discount. Here is an example run of my solution without a discount. Notice that the discounted total is not shown if there is no discount!
Welcome to the puppy food purchasing program

Please enter the following information
Number of five week old puppies: 23
Number of six week old puppies: 41
Number of seven week old puppies: 31
Number of eight week old puppies: 14
Did you get a discount? (y/n): n
This week we need:
Cans of food: 461
Bags of food: 36

Cost of food: 770.65
Tax amount: 30.83
Total cost: 801.48