I am trying to add the given percentage onto a number that already has that percentage added on.
I.e, The user defines 25% (this is not set could be any number percentage) I then add 25% onto the amount they invested to start with so for example:
Customer invests £10,000, I add 25% onto £10,000, which equals £12,500. AND THEN the following month I add the 25% onto the £12,500 from the month before, which should equal £15,625.
I keep getting the value of £15,000, and cannot work out how to store the given percentage in a variable itself and then add that percentage onto the Total amount.
Here is some code.
// Set the values...
Num = prompt("Enter a percentage using a decimal Number...");
interestRate = Num*100;
startCash = 10000;
total = startCash*interestRate/100+startCash;
month = 1;
// Inputting Text...
StartText = "Starting Money: £";
IntText = "Interest Earned: ";
TotalText = "Total Amount: £";
MonthText = "Month: ";
displayStart = StartText + startCash + "\n";
dispInt = IntText + interestRate + "\n";
dispTotal = TotalText + total + "\n";
dispMonth = MonthText + month + "\n";
dispvalue = displayStart + dispInt + dispTotal + dispMonth;
addInt = total + interestRate*100;
The total from compound interest calculated for the next month should be
addInt = total*interestRate/100 + total;
just like the fifth line of your code.