What input are you using? The reason I ask is because the way the code is now it will never print the result... unless i'm miss reading the question.
The reason it will not print any result is...
Type: Posts; User: User2009
What input are you using? The reason I ask is because the way the code is now it will never print the result... unless i'm miss reading the question.
The reason it will not print any result is...
What is the error that you get when you compile/run the code?
The key is in the data types of the variables.
The value in the variable "divided" will be 2 because of its data type which is int.
You can confirm this by adding this line:
...
The best way is to practice. :-)
Come up with some coding problems and then write the code for it. Or search for java coding problems on the internet.
If you get stuck just ask. There's always...
I'm assuming the "totally different" answer you're getting on a calculator is zero.
If that is the case then the reason is in the type of the variables... particularly the variable "divided".
...
I didn't get a chance to post earlier before term204's edits but it looks like you are on the right track
This is what I was going to post earlier... before your edits:
To calculate the total...
First, this just means that the class Bicicleta should have a default constructor "Bicicleta()" and its attributes (ruedaDelantera, ruedaTrasera and cuadro) should be set with default values. To do...
This is how I would count the number of statements:
1). Printsum (Int a, Int b) { ------------ Printsum is a function
2). Int result = a+ b;
3). If (result> 0)
4). Print ("Positive", result)...
I agree with Norm. That's how I would test the issue too, otherwise you'd spend too much time testing and you may never reproduce the specific circumstances where the error occurs.
I tested using...
Looks like the totals array was initialized with the starting value of trueLength, which was zero. Also it looks like the variable trueLength was calculated to be the total of the values in the...