This is a return to the fact that structured programming was new, back when goto statements, etc. were everywhere. Theoretically, ideally, you would never have to use breaks / continue and have only one return point. In fact, it can make your work a lot harder, making programs harder to write, harder to read and use more computing resources. Multiple returns, continuations, and breaks are middle men between truly structured programming and spaghetti code. Used correctly, there is nothing wrong with them.
As a rule, I found that they will only hide your code if you are already using bad methods that make it difficult to read your code (for example, writing huge blocks of logic, not parsing them, tightly linking objects, etc.).
If you're interested, here is a link to an interesting perspective, why NOT use them. And here is a look at why they are beneficial.
Many others have already answered with the code, but here is my snapshot :)
public class Main { public static void main(String args[]) { int sumOne = 1; int sumTwo = 1; int sumOneTotal = 0; int sumTwoTotal = 0; Scanner input = new Scanner(System.in); while(sumOne > 0 || sumTwo > 0){ System.out.print("Enter a number to add to first sum: "); sumOne = input.nextInt(); if (is_positive(sumOne)){ sumOneTotal = sum_numbers(sumOneTotal, sumOne); System.out.print("Enter a number to add to second sum: "); sumTwo = input.nextInt(); if(is_positive(sumTwo)){ sumTwoTotal = sum_numbers(sumTwoTotal, sumTwo); } } } System.out.printf("%1s%1d%12s%1s%1d", "First sum: ", sumOneTotal, " ", "Second sum: ", sumTwoTotal); return; } public static int sum_numbers(int x, int y){ int total = x + y; return total; } public static boolean is_positive(int x){ boolean is_pos = true; if(x < 0){ is_pos = false; } return is_pos; } }
I would say that reading is difficult now. The more to the right my code starts to gravitate, the more I'm sorry who needs to support it .. Of course, I could remove a level or two indents by wrapping (more) bits in the methods. Then it becomes easier to read, but there is a point where black boxing, every tiny bit of logic just seems superfluous ...