I am trying to write a program that asks a user for a ten digit number and then stores each digit in an array.
public class checksum {
public static void main(String[] args) {
int david[] = new int[10];
System.out.println("Enter your 10 digit number: ");
Scanner scan = new Scanner(System.in);
for (int i = 0; i < david.length; i++) {
david[i] = scan.nextInt();
}
System.out.println(david);
}
}
Can anyone tell me where I am going wrong?
Read it as
Stringand then populate array usingString.charAtOutput: