Page 1 of 1
Can't figure out whats wrong-help!
Posted: Sun Jun 13, 2010 3:11 pm
by canadian_angel
Hi I have to write a while php script that prints odd numbers between 1 and 49 then convert it into a for statement.
<?php // Script 6.2 - Odd Numbers
// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Print out 31 odd numbers.
for($i = 0;$i < 50;++$i) {
if($i % 2) {
echo "$i is odd!<br />\n";
}
?>
Re: Don't know where to begin-help!
Posted: Sun Jun 13, 2010 3:36 pm
by cpetercarter
You can't expect us to do your school assignments for you.
You could start by looking at
while loops. You want php to run a loop while the value of the investment is less than $1,000,000. In each iteration of the loop, you want php to increase the value of the investment by 15%; and you want to increment a counter which counts the number of times the loop runs.
I think you can figure it yourself from there.
Re: Don't know where to begin-help!
Posted: Sun Jun 13, 2010 5:02 pm
by canadian_angel
Wasn't expecting it done for me - just a little help is all! A hint- A clue anything! A place to start that's all!
Thanks!
Re: Don't know where to begin-help!
Posted: Sun Jun 13, 2010 5:25 pm
by internet-solution
cpetercarter has already given you the clue required.
Re: Don't know where to begin-help!
Posted: Sun Jun 13, 2010 6:43 pm
by canadian_angel
Thanks!