I want to read a number as a String, and split its characters to an integer array, and find the sum of it's digits by looping through that integers array.
This is my code so far:
public static void main(String[] args) {
Scanner S = new Scanner(System.in);
String Number = S.next();
int counterEnd = Number.length();
int sum = 0 ;
for ( int i = 0 ; i < counterEnd ; i++) {
sum += sum + (Number.charAt(i));
}
System.out.println(sum);
}
Unfortunately, this code prints the sum of ASCII not the digits.