RHS   Allan   SW construction Exercises Kindergarten


 

Kindergarten

In the Roskilde Kindergarten there are a number of children.
Each day the 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.
Only whole fruits are handed out; i.e. no slicing!

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, 3 oranges and 1 banana.
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 vary over time.
But in this program it is absolutely OK to hold the prices as constants in the program-code (we say that the values are "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!!

The following class-diagram describes a structure you can use in making your program:

  Class diagram for Kindergarten application    
     
 

 

Diagram of KindergartenMainWindow

   
     

Maintained by: Allan Helboe Nielsen
Updated: 3 November, 2005 1:04