Question: What number will this code output 4 3 , 4 2 , 4 4 or 4 1 ? public class Question { public static int

What number will this code output 43,42,44 or 41?
public class Question {
public static int checksum(String number){
int total =0;
for (int i =0; i number.length(); i++){
int digit = Integer.parseInt(""+ number.charAt(i))
if (i %2!=0){
digit *=2;
if (digit >10){
digit -=3;
}
}
total += digit;
}
return total;
}
public static void main(String[] args){
System.out.println(checksum("529764"));
}
}
What number will this code output 4 3 , 4 2 , 4 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!