Wondering how to get just numbers.So far it seems to work for the first two paragraphs of code but when it gets to the third piece it just doesnt seem to work.The if and else statement dont work. Dont worry about the last 3. I havent modified those to my liking yet. Thanks
print"Enter the starting amount: "; $startAmount = <stdin>; while($startAmount == ""){ print"Numbers only! Try again: "; $startAmount = <stdin>; };chomp($startAmount); print"Enter your current age: "; $startAge = <stdin>; while($startAge == ""){ print"Numbers only! Try again: "; $startAge = <stdin>; };chomp($startAge); print"Enter the age you want to retire: "; $endAge = <stdin>; while($endAge == ""){ if($endAge >= $startAge){ print"Age you want to retire must be greater than current age\n"; $endAge = <stdin>; }#ends if else{ print"Numbers only! Try again: "; $endAge = <stdin>; }#ends else };chomp($endAge); print "Enter amount deposited per year: "; $yearlyDeposit = <stdin>; chomp($yearlyDeposit); print "Enter the Annual interest rate: "; $annualInterest = <stdin>; chomp($annualInterest); print "Enter Expected Retirement Money: "; $expectedMoney = <stdin>; chomp($expectedMoney); system("pause");
In reply to Stdin for just numbers. by programmercarlito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |