Skip to content

Commit

Permalink
Update CheckDigit.java
Browse files Browse the repository at this point in the history
  • Loading branch information
PrestonChengAPCSA authored Apr 30, 2024
1 parent 0668ccb commit bb7ca90
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/java/CheckDigit.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ public static int getCheck(int num)
* is between two and seven, inclusive.
* numWithCheckDigit >= 0
*/
public static boolean isValid(int numWithCheckDigit)
public static boolean isValid(int numWithCheckDigit)
{
/* to be implemented in part (b) */
int check1 = getCheck(numWithCheckDigit / 10);
int check2 = check % 10;
if(check1 == check2){
if(numWithCheckDigit%10==getCheck(numWithCheckDigit/10)){
return true;
}
return false;
}

return false;
}

/** Returns the number of digits in num. */
public static int getNumberOfDigits(int num)
Expand Down

0 comments on commit bb7ca90

Please sign in to comment.