id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david_petty@psbma.org > isValidISBN
prev  |  next  |  chance

An ISBN has thirteen digits. The first twelve identify the country in which the book was printed, the publisher, and the individual book. The thirteenth digit is the "check digit." It is chosen in such a way that (d1 + 3d2 + d3 + 3d4 + ... + d11 + 3d12 + d13) mod 10 = 0 where d1, d2, d3..., d13 are digits of the ISBN. mod stands for modulo division (same as % in Java for non-negative dividends). Write a method: public boolean isValidISBN(long isbn) that returns true if isbn represents a valid ISBN, false otherwise. (Thanks to Katerina Soltan.)


isValidISBN(9781245617412) → false
isValidISBN(9781604596908) → true
isValidISBN(8580001040332) → true

...Save, Compile, Run (ctrl-enter)

public boolean isValidISBN(long isbn) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 50 Post-solution available

Copyright Nick Parlante 2017 - privacy