Joshua Jones

Greenhorn
+ Follow
since Aug 30, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joshua Jones

never mind solved by doing textfield.setText(Double.toString(Variable));
11 years ago


so I have some text fields in java Swing that I'm trying to populate with data in these variables, now the top block of code works fine because the variables are of type String and the setText(String); method works

My problem lies in not being able to set the value of my textfields to a variable of type double, when I try i get the error actual argument double cannot be converted to java.lang.string.


Is there any way of parsing the variables contents and then converting that to string or ?
11 years ago

Jeff Verdegan wrote:Create a counter before you enter your loop. Increment it each pass through the loop. Use that as the index into the other array.

Or, if you're using Lists rather than arrays, just iterate both Lists at the same time.

However, if you're using a "parallel array" (or "parallel list") approach, that's usually a sign of a design error. A better approach would probably be to define a class that contains one "row" across corresponding elements of all of your arrays.




how would I create such a counter, I have tried but I just end up printing the value of how many passes the loop makes overall not how many passes till the if statement is met?
11 years ago


Let me explain my code, and what I'm having trouble with,

ok so my code here searches through an arrayList and populates some fields with the information held in an element, now I have corresponding arrays that contain other data in the same element position in their respective arrays, so the index for this array List's useful information is the same as the index of the other Arrays, now I can display my searched results element completely fine, but I want to produce a similar result for 2 more arrays without having to search either one of them, by using the array index number, I would like to know of any ideas of how i can return the index number of the current element that satisfies the if statement.
11 years ago

Jeff Verdegan wrote:

Joshua Jones wrote:now I would like to make some sort of selection to "update" the value of TypeVal with the implied values based on whether ProjectType is either Consultancy or development so I can make calculations with that value.



And the initial code you posted does just that. (Aside from the syntax error of not covering the situation where it's neither "Consutancy" no "Development".)

So what specific problem are you having?



the value of the TypeVal does not change
11 years ago

Jeff Verdegan wrote:

Joshua Jones wrote:
Assume the Conditions are true in both cases. the Project Type will always be either Consultancy or Development. I just want to get the value of Typeval out of the if statement so I can use it in calculations



You and I can make that assumption, but the compiler can't know that this will be the case. You have to cover every possible case.

The usual way would be something like this:




Thats I fully comprehend that but in my scenario there is no eventuality other than the value being consultancy or development fine but it doesn't really answer my question, ok let me explain the scenario rather than showing you guys some if statements.

ok the User will select a value either "Consultancy" or "Development" this value will be saved in the variable ProjectType ok,
obviously the selection of one or the other has implications in my calculations for things in my system. now the value of Consultancy should imply a value of 0.5 in the variable TypeVal, and likewise the value of Development should imply the value of 1.0 in this same variable, now I would like to make some sort of selection to "update" the value of TypeVal with the implied values based on whether ProjectType is either Consultancy or development so I can make calculations with that value.
11 years ago

Paul Clapham wrote:

Mohana Rao Sv wrote:Is your if condition true in either of the cases.



Exactly. And what value do you want TypeVal to have if it isn't?




Assume the Conditions are true in both cases. the Project Type will always be either Consultancy or Development. I just want to get the value of Typeval out of the if statement so I can use it in calculations
11 years ago
Assume the Conditions are true in both cases. the Project Type will always be either Consultancy or Development. I just want to get the value of Typeval out of the if statement so I can use it in calculations
11 years ago


Basicly i am trying to return the value of a Double based on the value of a String and I cant seem to get the value out at the end to populate the variable TypeVal.

any thoughts ?
11 years ago
I have a java application with classes ready to serve as a model, but I don't really know how I can fit the JSP's and ?actionfor/beanS? together to make a proper struts application

Basically could someone list the things I need for everything to work. and also could someone explain how the struts-config, and web.xml files work I really am lost. using Struts 1 btw but any library is fine I just need someone to start me off so I can integrate my java classes with some forms on a few jsp's and run it all in tomcat6 thanks.
12 years ago