Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this question you must write a java class called ISBN and a client class called ISBNClient. The partial ISBN class is given below. (For

For this question you must write a java class called ISBN and a client class called

ISBNClient. The partial ISBN class is given below. (For this assignment, you will have to

submit 2 .java files: one for the ISBN class that represents ISBN-10 numbers for books

and the other one for the ISBNClient class.

//a ISBN class that stores the 2 fields for ISBN calculation

public class ISBN

{ private String

digits;

private String checkSymbol;

//constructs a new ISBN with the given fields

public ISBN(String digits, String checkSymbol)

// getter/accessors that returns the fields' values

public String getDigits()

public String getCheckSymbol()

//returns true if the ISBN is valid else returns false. You will

//need to extract each digit to calculate checksum. You can use

//charAt or substring methods then convert them to integer and

//The algorithm to generate the checksum is given below.

public boolean isValid()

// returns the string representation of the ISBN

// ISBN should be printed in correct format eg: 0-13-394302-X.

public String toString()

...

}

- Write the client class ISBNClient that asks the user to enter the values for digits and

checkSymbol and creates an object of class ISBN and uses the data entered to initialize

its fields. Print out ISBN object. Then print out if the given ISBN number is valid or not.

Note:

ISBN, the International Standard Book Number, is a special code printed on most books,

such as:

0-13-394302-X

1-323-79826-9

The first 9 digits are assigned by a book publisher, and the last symbol is computed from

these previous digits by a "weighted sum" as follows.

First sum the first digit, and

2 times the second digit, plus

3 times the third digit, plus

etc, to

9 times the ninth digit.

Then divide this sum by 11 and if it is less than 10 then the remainder becomes the

checkSum; otherwise the checkSum is the symbol "X".

For example: in the above case

013394302

sum = 0 +2*1+ 3*3 + 4*3 + 5*9 + 6*4+7*3+8*0+9*2

= 0 + 2+9++12+45+24+21+0+18

= 131

check = 131 % 11

= 10

so the check symbol is 'X".

Similarly in the second example:

1-323-79826

the check sum is 9.

If the computed check is not equal to the check symbol, then there has been an error in

the digits. This provides a form of error detection.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago