
-----------------------------------
P-Nut311
Thu Nov 25, 2004 10:09 pm

Conversion Help Needed
-----------------------------------
I want a user to enter either a decimal or percentage, but the program must convert the percentages into decimals. How do I go about doing this? Whenever I attempt this, my program converts all numbers inputted. Can someone help me??

Thanks

-----------------------------------
wtd
Thu Nov 25, 2004 10:12 pm


-----------------------------------
Show us the code you have.

-----------------------------------
P-Nut311
Fri Nov 26, 2004 2:33 pm


-----------------------------------
Here's what I have so far...

%Investment program
var investment, interest : real
var term : int
var plan : string
locate (12, 29)
put "Cash Investment Program"
delay (5000)
cls
put "Please enter your cash investment: $" ..
get investment
cls
put "Please enter your interest rate: %" ..
get interest
if interest >= 0 then
    interest := interest / 100
elsif interest >= 0.00 then
    cls
end if
cls


I know that code under "get interest" is wrong. How do I make it so that when the user inputs a decimal, the program will leave the number alone, but when the user inputs a percentage, the program will convert it to a decimal?

Thanks

-----------------------------------
Viper
Fri Nov 26, 2004 3:27 pm


-----------------------------------
ok wut exactly is this program supposed 2 do

-----------------------------------
Viper
Fri Nov 26, 2004 3:28 pm


-----------------------------------
try that

var p:real
var n:real
var i:real
var A:real

put "how much money is in your bank?"..
get p
put "how many mounths will it be in there for?"..
get n
put "what is the intrest you are getting from the bank?"..
get i
 A:= p *(1+i/12)**n
put " you Have",p,"$ in the bank,"  
put "it will be in ther for",n,"mounths, at a ",i,"% intrest rate" 
put "you should have" ,A, " when you take it out"

-----------------------------------
P-Nut311
Fri Nov 26, 2004 5:36 pm


-----------------------------------
The program is supposed to take the interest and if the user inputs a percentage, then the program must convert it into a decimal. If the user inputs a decimal, then the program should keep the decimal as it is.

-----------------------------------
wtd
Fri Nov 26, 2004 7:01 pm


-----------------------------------
Here's what I have so far...

%Investment program
var investment, interest : real
var term : int
var plan : string
locate (12, 29)
put "Cash Investment Program"
delay (5000)
cls
put "Please enter your cash investment: $" ..
get investment
cls
put "Please enter your interest rate: %" ..
get interest
if interest >= 0 then
    interest := interest / 100
elsif interest >= 0.00 then
    cls
end if
cls


I know that code under "get interest" is wrong. How do I make it so that when the user inputs a decimal, the program will leave the number alone, but when the user inputs a percentage, the program will convert it to a decimal?

Thanks

By declaring "interest" as "real", you ensure that it will always be a decimal number.  There's no need for conversion.

-----------------------------------
con.focus
Sun Nov 28, 2004 9:19 pm


-----------------------------------
try that

var p:real
var n:real
var i:real
var A:real

put "how much money is in your bank?"..
get p
put "how many mounths will it be in there for?"..
get n
put "what is the intrest you are getting from the bank?"..
get i
 A:= p *(1+i/12)**n
put " you Have",p,"$ in the bank,"  
put "it will be in ther for",n,"mounths, at a ",i,"% intrest rate" 
put "you should have" ,A, " when you take it out"

you should really give name to your variables  espially in long code (make it ezer for ppl to read n figure out wut they mean or do

-----------------------------------
wtd
Sun Nov 28, 2004 9:30 pm


-----------------------------------
try that

var p:real
var n:real
var i:real
var A:real

put "how much money is in your bank?"..
get p
put "how many mounths will it be in there for?"..
get n
put "what is the intrest you are getting from the bank?"..
get i
 A:= p *(1+i/12)**n
put " you Have",p,"$ in the bank,"  
put "it will be in ther for",n,"mounths, at a ",i,"% intrest rate" 
put "you should have" ,A, " when you take it out"

you should really give meaningful name to your variables  espially in long code (make it ezer for ppl to read n figure out wut they mean or do

Better.  ;)
