thiba...@mweb.co.za wrote:

> Hi

> I would like to write a program that takes as input the daily wage of a

> labourer, determine the wage owed to him for a week's work, determine the

> amount owed to the labourer for overtime work and then subtract any loan

> the labourer may owe to the user from the amount owed to him.

> I would, however, also like the program to tell the user the exact amount

> of notes/coins to be paid out for a certain amount. I used real numbers

> in my program to make provision for the cents and this is where I

> encountered the following problem:

> Sometimes the computer rounds off the last cent and thus displays the

> wrong amount of cents to be paid out. For example, say the amount to be

> paid out requires 2 cents, but the computer rounds the number off and

> there is displayed on the screen that 3 cents need to be paid out.

> I must round the number to be displayed on the screen off, or otherwise I

> get a large decimal number. The following is the code I used:

> (starting from the if to check for the 2 cents)

> if (remainder>=0.02) and (remainder<0.05) then

> writeln('You can pay with ',trunc(remainder/0.02), '2c coins.');

> m:=trunc(remainder/0.02);

> remainder:=remainder-0.02*m;

> (this is the problem part)

> if (remainder>=0.01) and (remainder<0.02) then

> writeln('You can pay with ',trunc(remainder/0.01), '1 coins.');

> Any suggestions in getting past this problem would be greatly

> appreciated. I have also included the entire program as zipped

> attachment.

> thanks

> thiba...@mweb.co.za