Sum numbers till a number using do while loop
import java.util.Scanner; public class SumAllDo { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Please enter the max number:"); int max = input.nextInt(); int i = 0; int sum = 0; do {/*w w w .j av a2s. co m*/ System.out.println("Number " + i); sum += i; i++; } while ( i <= max); System.out.println("Sum of All is " + sum); } }