*Given the cash price of an item together with the percentage rate required, calculate the HP charges for a given repayment.*

I had no idea how hire purchasing works, so I had a look round the web for some information. As far as I can tell a total price is agreed upon and then the buyer pays equal amounts every month until they reach that amount. They usually pay a deposit, but the question doesn't mention that so I wont include that part of the deal.

I'm not certain that's how it works, but I can always update my answer if I discover it works differently.

`<?`

` // a random cash price of an item in pounds`

` $cash_price = mt_rand(5, 20);`

` // a random percentage rate`

` $percentage_rate = mt_rand(5, 50);`

` // a random number of repayment periods`

` $repayments = mt_rand(2, 10);`

` `

` // the total amount to pay is the cash price plus the percentage`

` $total = $cash_price + ($cash_price * ($percentage_rate / 100));`

` `

` // the amount to pay each month is the total amount`

` // divided by the number of repayments`

` $repayment = $total / $repayments;`

` `

` // output the original values`

` echo . number_format($cash_price, 2) . '<br/>'`

` . 'Percentage Rate: ' . $percentage_rate . '%<br/>'`

` . 'Repayments: ' . $repayments;`

` `

` // output the total amount to be paid `

` echo . number_format($repayment, 2) . '</b>';`

`?>`

Which produces:

Cash Price: £10.00

Percentage Rate: 33%

Repayments: 10

Monthly Amount: £1.33

- Novemember 6, 2005 - Added solution 1.

© 2004-18 robson | cc unless stated