Do While Loop

Do…while loop is similar to while loop. The body of do…while is executed once before the condition is checked.

do {
// codes inside body of do while loop
}

public static void main(String[] args) {

Double number, sum = 0.0;
Scanner input = new Scanner(System.in);

do {
System.out.print(“Enter a number: “);
number = input.nextDouble();
sum += number;
} while (number != 0.0);

System.out.println(“Sum = ” + sum);
}