I don't see what you need a loop for.
I'm done for tonight. Back tomorrow.
Type: Posts; User: Norm
I don't see what you need a loop for.
I'm done for tonight. Back tomorrow.
The while loop is for the validate step. The computation step follows the validation step.
If the computation step requires a loop, it would be a new loop, not part of the validation loop.
From post#19:
Here is some pseudo code:
get input from user
validate input
use input in computations <<<<<<<<<< NOTE this comes after validate input
print out results <<<<<<<<< NOTE this...
Make the list of steps for the program in pseudo code before coding the program.
When you have the list of steps, then write the code.
Don't write code before you have gotten the steps figured out....
You could do the computations after getting the input
and validating it.
Break down the step: Compute the results
into simple single steps.
Is there any need for a loop to compute the results?
What step in the list of pseudo code steps does the code in the do loop accomplish?
What happens when the code in post#44 is compiled and executed?
If you would label the end of methods it...
It is confusing to have comments that are wrong. The end of a class is different than the end of a method.
Earlier there was pseudo code that listed a possible order of the steps to solve the...
}//End validateInput method <<<<<<<A
}//End main method <<<<<<<<<<B
There is an error right there. It looks like the end of the main() method at B includes another method ending at A....
Have you fixed the compiler errors yet?
What are the steps: method1 and method2? Their names don't have any relationship to what the program is doing.
The formatting for the code is poor which makes it very hard to read.
Review this pseudo code from an earlier post as a suggestion for what order to do things:
get input from user
validate input...
That's one requirement: that all {s must have a pairing }
One way to check for unpaired {}s
Print out the source code on paper and use a pencil: circle the { and draw a line to its } and circle...
Perhaps you need to take a break and try something else. If you are having counting and pairing {s and }s in a small program, I don't know what will happen when you try to write a bigger program.
To clearly see which } ends a method,
label all the }s that end a method with a comment:
} // end main()
} // end validateInput()
Each method should have only one ending }
Where is the ending } for the main() method?
To clearly see which } ends a method,
label all the }s that end a method with a comment:
} // end main()
} // end validateInput()
For readability the } in the above line should be on the next line and inline below the statement with the pairing }
You need to check the correct pairing of each { with a }.
There should be a...
What happens when you compile and execute the code?
If there are errors, then its not correct.
If you get the right answers, then it could be correct.
Where is line 51 that is mentioned in the...
Wait until you are at your computer to send messages.
You have left off the source line numbers for the compiler errors making it hard to find them.
Here is a sample of an error message from the javac command:
TestSorts.java:138: cannot find...
Here is some pseudo code:
get input from user
validate input
use input in computations
print out results
Also posted at: ValidInput errors and return error. - Dev Shed
See post#6
When you get errors, you need to copy the full text of the error messages and paste it here.
public static void main(String[] args) {
// TODO Auto-generated method stub...
Where will it print that message? How does the code that prints the message get executed? If you don't call a method, the code in the method will not be executed.
Did you compile the code with...
Copy and paste here the text of any error messages you want help with along with the code.