In my code, I have to take two numbers, such as 3 and 11, find the odd numbers between them (inclusive), add the odd numbers together and print the sum. I've looked up ways to do this and all the ways I've tried have given me a different result each time.
Can anyone help me figure out what I'm doing wrong? https://repl.it/@20rduncan/035-Sum-Odds-in-Range
Sum of Odd numbers - Java
In my code, I have to take two numbers, such as 3 and 11, find the odd numbers between them (inclusive), add the odd numbers together and print the sum. I've looked up ways to do this and all the ways I've tried have given me a different result each time.
Can anyone help me figure out what I'm doing wrong?
https://repl.it/@20rduncan/035-Sum-Odds-in-Range
All you needed to do was add the odd numbers to a total and print the total. (Also,
printline()
on line 18 should beprintln()
)New Code
Ah, I see what you mean. I feel kind of stupid I couldn't figure that out.
Thanks! :)