nickthrolson Posted July 10, 2009 Share Posted July 10, 2009 Let us say we wanted to create a savings table. The columns represent the interest rates (6,7,8,9,10) percent. The rows represent the years (1,2,3, ... up to 12) If the savings in any given cell where = (1+interest)^(number of years) where in this case ^ is the power then print the table I need help with this can anyone give me example how to start this off? for class is I'm in for college reading the book cant find any similar examples. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/165454-savings-table/ Share on other sites More sharing options...
ignace Posted July 10, 2009 Share Posted July 10, 2009 Is this what you want to create? +----------+----------------+ | | 6% | .. +----------+----------------+ | 1st year | base+intrest^1 | .. +----------+----------------+ | 2nd year | base+intrest^2 | .. +----------+----------------+ | 3th year | base+intrest^3 | .. +----------+----------------+ Then this should do it: <?php $base = 100; $years = range(1, 12); $percents = range(6, 10); $number_of_years = sizeof($years); $total_percentages = sizeof($percents); for ($i = 0; $i < $number_of_years; ++$i) { for ($j = 0; $j < $total_percentages; ++$j) { $base += ($base * ($percents[$j] / 100))^$years[$i]; print 'Year: '. $years[$i] . ' Percentage: ' . $percents[$j] . ' Base+Intrest: ' . $base . '<br>'; } } ?> It misses the markup to create the table though Quote Link to comment https://forums.phpfreaks.com/topic/165454-savings-table/#findComment-872658 Share on other sites More sharing options...
ignace Posted July 10, 2009 Share Posted July 10, 2009 This produces this output: Year: 1 Percentage: 6 Base+Intrest: 107 ... Year: 12 Percentage: 10 Base+Intrest: 10120 Quote Link to comment https://forums.phpfreaks.com/topic/165454-savings-table/#findComment-872662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.