Are you saying that only the variables: a,b,c,d will work and that the order of their values given in the ValVarPairs.txt file must be in this order: a,b,c,d?
That should be documented in the...
Type: Posts; User: Norm
Are you saying that only the variables: a,b,c,d will work and that the order of their values given in the ValVarPairs.txt file must be in this order: a,b,c,d?
That should be documented in the...
Yes, that looks like the error the code will get.
What assumptions does the code make about the variables' names and the order they are defined in the ValVarPairs.txt file?
Sorry, I don't know PHP.
What happened when you changed the variables: c and d to x and y?
Try it and see what happens. Give x and y different values for clarity in showing test results.
I think you will get a surprise.
You'll need to get some help again to fix the code to make it...
Glad you got it working.
--- Update ---
What changes would you have to make to the program if the ValVarPairs.txt file were changed to contain these numbers-> a=100,b=5,x=10,y=13? Then the...
Is that the correct answer?
Does the program work for several different input expressions?
That looks like the code does not find the values for the variable names in the expression but just uses the 4 values in the order that they were saved in the ValVarPairs.txt file.
Try another...
You didn't include the expression the program was to evalute???
Given these values: a=100,b=5,c=10,d=13
Looking at the printout and associating the contents of result with the values of the...
That's what I am trying to do: show you how to debug the code and find the problem. To do that you need to add println statements, execute the program, copy the output and paste it here. Hopefully...
Yes, nothing that was done up to now has changed the program's results. The purpose of debugging a program is to find out why it is not generating the correct results. When that is understood, then...
make sure all {s having a pairing }
If the statements are properly formatted, it is a lot easier
class AClass {
void aMethod() {
if(cond) {
// do something
...
Please copy the full text of the compiler's error messages and paste it here.
The {}s are still not correctly placed. Their positions should reflect the nesting level of the statements they...
Why is there a { on the next to last line?
Check that all the }s have a pairing {.
In general there should NOT be any code on the same line following a {.
Also only put one statement per...
What prints out when the program executes?
The ids are not unique. I see res2 in two different places.
Also there isn't a println() in the else
Also there needs to be a println() outside the...
There are 2 places where result gets assigned a value that don't have println() statements in the code in post#19 that did have them in post#15. You need to have println() statements after ALL the...
You need to update the code and post the new version with the changed id strings and the added {}s following the if and else statements.
What printed out?
All the println()s have the same id String: "1res" so you won't be able to tell which println printed which line of output. Change them so that are all different: 1res, 2res,...
Don't give up on debugging the code. You will have to know how to debug for all the programs that you write.
What did the debug println statements print out?
Copy and paste what is printed out...
Put a println statement AFTER EVERY line where the variable result is assigned a value:
result = someValue; // this statement assigns result a value
System.out.println("1res="+result); //...
Start with printing out the value of the one variable: result and see what is printed. If that doesn't help, you can always add more println statements for other variables.
Here is a sample from your code:
System.out.println(result);
I'd change it to include an id string so you know which println's output you are seeing:
...
Time to start debugging to see where the code is going wrong. Add some println statements to print out the values of the variables as the code executes so you can see where the code is going wrong.
What is the correct answer?
Can you copy the contents of the command prompt window from when you execute the program that shows how the program is executed and what the program prints out when it executes?
To copy the...