Skip to content
Sum of Odd numbers - Java
Profile icon
20rduncan

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

You are viewing a single comment. View All
Profile icon
Geocube101

All you needed to do was add the odd numbers to a total and print the total. (Also, printline() on line 18 should be println())
New Code

Profile icon
20rduncan

Ah, I see what you mean. I feel kind of stupid I couldn't figure that out.
Thanks! :)