stephenrulz02
12-05-2003, 03:52 AM
I have tried a search, but none of the results solved my problem :(
I wrote this code for no particular reason, just to have a calculator to find 90% of the value entered.
I have attached a txt file with the code and a working calculator can be found at:
http://www.angelfire.com/un/neoguide/powerpets/javacalc.html
To get it to work, you:
1. Enter a Value
2. Click the button labeled 'PT'
3. and then 'Click to Calculate' to get the answer
but I realized I would like this calculator to do more, to be able to round the numbers up or down.
For example:
If after clicking 'Click to Calculate' the number is found is 2.44, I would like it to display 2 and if it is 2.45 it should display a 3
I think I have found the funtion I need to write some if statements in, but being new to Java I don't really know how to get it to do what I want.
function finish()
{
document.Screen.secret.value = eval(document.Screen.secret.value)
FINAL = document.Screen.secret.value
document.Screen.display.value = FINAL
}
That function is the one called when 'Click to Calculate' is pressed.
Is there anyway this code can be modifyed to allow this rounding off?
Thanks everyone for your time :)
I wrote this code for no particular reason, just to have a calculator to find 90% of the value entered.
I have attached a txt file with the code and a working calculator can be found at:
http://www.angelfire.com/un/neoguide/powerpets/javacalc.html
To get it to work, you:
1. Enter a Value
2. Click the button labeled 'PT'
3. and then 'Click to Calculate' to get the answer
but I realized I would like this calculator to do more, to be able to round the numbers up or down.
For example:
If after clicking 'Click to Calculate' the number is found is 2.44, I would like it to display 2 and if it is 2.45 it should display a 3
I think I have found the funtion I need to write some if statements in, but being new to Java I don't really know how to get it to do what I want.
function finish()
{
document.Screen.secret.value = eval(document.Screen.secret.value)
FINAL = document.Screen.secret.value
document.Screen.display.value = FINAL
}
That function is the one called when 'Click to Calculate' is pressed.
Is there anyway this code can be modifyed to allow this rounding off?
Thanks everyone for your time :)