Forums Register Login

is it possible to permanently change the value of a double variable by using an if statement?

+Pie Number of slices to send: Send
is it possible to permanently change the value of a double variable by using an if statement? here is the code i have so far but it doesn't work. Any help please?



thank you
+Pie Number of slices to send: Send
What do you mean by "it doesn't work"?
What result are you getting and what result are you expecting?
+Pie Number of slices to send: Send
 

Dave Tolls wrote:What do you mean by "it doesn't work"?
What result are you getting and what result are you expecting?



well i want double EURtoGBP = 0.8482; to change to whatever the user inputs into changeEuro text field
+Pie Number of slices to send: Send
OK.
I suggest adding some logging in there, println() calls would do, to log what the value of everything is, and what path through that bit of code it takes.
+Pie Number of slices to send: Send
 

Liam Rice wrote:
well i want double EURtoGBP = 0.8482; to change to whatever the user inputs into changeEuro text field



From the code (ie. name of the method), I am going to speculate that there is a save button somewhere in the application. And that code that reads and sets the field is only executed when the button is pressed.... If I am wrong regarding this, then never mind ...

Anyway, you can place action listeners on text fields, so you can execute code, and hence, change variables, as soon as the user changes the fields. You still need to check it to make sure that the field is valid (and not blank), but this should not depend on the user pressing a button.

Henry
+Pie Number of slices to send: Send
 

Henry Wong wrote:

Liam Rice wrote:
well i want double EURtoGBP = 0.8482; to change to whatever the user inputs into changeEuro text field



From the code (ie. name of the method), I am going to speculate that there is a save button somewhere in the application. And that code that reads and sets the field is only executed when the button is pressed.... If I am wrong regarding this, then never mind ...

Anyway, you can place action listeners on text fields, so you can execute code, and hence, change variables, as soon as the user changes the fields. You still need to check it to make sure that the field is valid (and not blank), but this should not depend on the user pressing a button.

Henry



yes, this part of the program is for the admin to go to to change the exchange rate that the actual application uses within the calculation (to update). The user selects an exchange rate that they want to change, e.g. GBPtoUSD and they put in the updated exchange rate and then press save. At this point i am then wanting the user input to replace the GBPtoUSD once the save button is clicked
+Pie Number of slices to send: Send
If you have started the program in a way that you can see output to the command line (or a command box if in an IDE), put some debugging lines in the code, like:

Putting "// debug" after each line will help you find and remove the debugging lines after you don't need them.
+Pie Number of slices to send: Send
I'd add one before the 'if' statement as well:
I do some of my very best work in water. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 317 times.
Similar Threads
currency converter not working
number format exception
Help with methods, getters and setters
Problem with calculator
New to Netbeans - Project Question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:51:40.