Java code which takes integer inputs till the user enters 0 and print the sum of all numbers.

class Sum{
public static void main(String[] args) {
    System.out.println("Enter the number to know their 
    sum & Press 0 to get the Sum");
    Scanner sc = new Scanner(System.in);
    int s = 0;
    int n;

 do {
         n = sc.nextInt();
        s = s + n;
    }while (n!=0);
    System.out.println("Sum = " + s);
   }
}