Your total amount calculation is wrong :
totalAmount = (((40.0 * weeks) * discount / 100) - (40.0 * weeks));
instead it should be :
totalAmount = (40.0 * weeks)) - (((40.0 * weeks) * discount / 100) ;
so for 2 weeks : cost will be 40*2 = 80$
and 20% discount : 64$
totalAmount = (40.0 * weeks)) - (((40.0 * weeks) * discount / 100) ;
= 80 - (80 * 0.2)
= 80 - 16
= 64$
hope this helps