Here I in this task I need to use the generated string data to loop over all characters on it then sum only the numbers within the string. example: If we have this data string
5f395d07369071a505ef926527de2ac53e8c29e103dc63398315bc276224b81a
Then the result will be when taking only the numbers and adding them together is 2407
this is the code :
String studentId="22011151";
String studentName="Abed Alrahman Abuhilal";
int total=0;
String data =generateData(studentId); //here is a method I didn't show
I have a logic error here
for(int i=0; i < data.length(); i++) {
Boolean ok = Character.isDigit(data.charAt(i));
total+=data.charAt(i);
System.out.println("StudentId:"+studentId+" my name is:"+studentName+" total is:"+total);