RHS -> Allan-> SWC ->Exercises ->Kindergarten

Kindergarten

Each day the Roskilde Kindergarten receives a load of fruits consisting of a mix of apples, oranges and bananas.
The fruits of each type must be distributed among the children.

Note: Only whole pieces of fruits are handed out; i.e. no slicing, cutting or breaking apart!

Fruits, which are left over, must be bought by the staff employers for the following prices:

1 apple : 1.00 DKK
1 orange: 1.25 DKK
1 banana: 1.50 DKK

The assignment
You are to create a program with the following input, calculations and output (look below for a diagram and hints):

Input

Calculations

Output

Example
Assume there is 14 children in the kindergarten. Also assume that this day they got 30 apples, 55 oranges and 17 bananas.

Each cild then recieves 2 apples (30 / 14), 3 oranges (55 / 14) and 1 banana (17 / 14).

The staff bys the rest: 2 apples (sold for 2 DKK), 13 oranges (sold for 16.25 DKK) and 3 bananas (sold for 4.5 DKK).
The total amount recieved by the sale is thus 22.75 DKK.

Hints
For a program like this to be useful in the real world it should be possible to change the prices used for the sale - they are likely to change over time.
But in this program it is absolutely OK to hold the prices as constants in the program-code ("hard-coded").

In general you should not try to make your programs fancy and flexible - you'll end up spending a lot of time strugling with small details that are not important right now.
For now you should focus on getting the program to work (use KISS strategy)!!

Below is an example of how your applications UI could look like:

     
   

Maintained by: Allan Helboe
Updated: 28 November, 2007 15:57