Hi everyone,
New question, new headache
I have a list of books which I have added an overdue date, no problem so far. But now I need to put a fine if the overdue pass a certain date.
If more than 200 days overdue, user pay full replacement. If less 200 days and if it worth more than £50, the user is fine 2% of the replacement cost for everyday the book is overdue. And if the overdue is less than 200 days but under £50, user is fined 1% of the replacement cost for every day that the book is overdue.
The function should take 2 arguments, the number of book and the number of days overdue.
My coding for the overdue date is ok, but how do I organise myself for the catalogue combine the overdue date with the levy fine, and calculate the fine? I don't know where to start
CODE
document.write('<BR><BR>BARSETSHIRE COUNTY LIBRARIES<BR>');
document.write('==============================<BR>');
document.write('<BR>Administrator interface - Showing catalogue<BR><BR>');
showCatalogue();
var currentDate = 300;
var bookArray = ['Framley Parsonage 1st Ed', 'Lady, Don\'t Fall Backwards', 'How to Win Friends 2nd Ed ', 'The Death of Harry Potter', 'The Kama Sutra (unexpurgated)', 'Little Noddy Goes to the Moon', 'Life of Tristram Shandy 1st ed', 'Remembrance of Things Past', 'On Her Majesty\'s Secret Service', 'The Wind-up Bird Chronicle', 'Last Exit to Birmingham', 'Love in the Time of Cholera', 'Java for Dummies 2nd Ed', 'The French Revolution', 'She Married a Duke', 'The Works of Shakespeare', 'A Tale of Two Cities', 'The Tailor of Gloucester', 'The Diary of a Nobody', 'The A to Z of Loving'];
var dueArray = [0, 0, 345, 137, 0, 0, 0, 181, 0, 0, 0, 131, 284, 0, 0, 56, 315,0, 0, 0];
function showCatalogue(){
for(count=0; count < bookArray.length; count++){
dateDue = currentDate - dueArray[count];
document.write(count + '------' + bookArray[count] +'------' + daysOverDue(dateDue) + '<BR>');
}
}
function daysOverDue(dateDue)
{
if(dateDue < 300)
{
return ("overdue by" + ' ' + dateDue + ' ' + 'days!');
}
else(dateDue > 300)
{
return ("on shelf");
}
}
//below is how I start with the function levyFine
var replacementCostArray = [10.99, 3.87, 5.99, 11.99, 15.45, 3.99, 250.0, 58.70, 4.99, 9.99, 7.99, 7.99, 12.50, 75.0, 3.45, 15.0, 12.99, 5.50, 7.99, 6.99];
var fineRate = 1/100;
function levyFine(replacementCost)
{
if ((replacementCost == 6) && (replacementCost == 7))
{
return ("Fine of" + ' ' + '£' + replacementCostArray + fineRate);
}
}
//I'm confused how to combine levyFine and dateDue