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

What number will this code output 87,83,72 or 64?
public class Question {
public static int checksum(String number){
int total =0;
boolean multiply = false;
for (int i =0; i number.length(); i++){
int digit = Integer.parseInt(""+ number.charAt(i));
if (multiply){
digit *=4;
if (digit >15){
digit -=5;
}
}
total += digit;
multiply =!multiply;
}
return total;
}
public static void main(String[] args){
System.out.println(checksum("9845312"));
}
}
What number will this code output 8 7 , 8 3 , 7 2

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!