Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Dec 23rd, 2005, 5:29 AM   #1
scuzzman
Newbie
 
Join Date: Dec 2005
Posts: 2
Rep Power: 0 scuzzman is on a distinguished road
A simple script isn't working correctly

I'm having trouble getting a very simple script to run and cannot figure out the problem. The script is as follows:
#!/usr/bin/perl -w

$level = 1;
$prod = (20 * $level) * (1.1 ** $level);

print "What is the amount of energy you\'re trying to accumulate? ";
chomp ( $goal = <STDIN> );

while ($prod <= $goal) {
  # print "$level\n"; # DEBUG: print the current level
  $level++;
}

print "\nRequired level for $goal energy from a solar planet is $level\n";
The problem is that the $prod never changes from 22 (which is what it evaluates to when $level = 1). Because $prod is based on the value of $level, shouldn't $prod change when $level does?
scuzzman is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:30 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC