Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Directions: input ISBN number from user and output Valid if the number is valid or Invalid otherwise. Terminate the input when the user enters

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

C++

Directions: input ISBN number from user and output Valid if the number is valid or Invalid otherwise. Terminate the input when the user enters done

ISBN

number for a book

10 digit number made up of 4 sections

each section seperated by -

Example: ISBN number is: 1-214-02031-3

1 represents a country

must be 1 digit

214 represents the publisher

must be 3 digits

02031 reprsents the book number

must be 5 digits

3 is the checksum

must be 1 digit or the letter x

checksum is a digit to see if the ISBN number is a valid number

If checksum is x , then that represents the digit 10

Weight is associated with each digit

example: 1-214-02031-3

10 with the first digit

1 in the example

9 with the second digit

2 in the example

8 with the third digit

1 in the example

7 with the forth digit

4 in the example

6 with the fifth digit

0 in the example

5 with the sixth digit

2 in the example

4 with the seventh digit

0 in the example

3 with the eight digit

3 in the example

2 with the ninth digit

1 in the example

1 with the tenth digit

3 in the example

Checking valid

Multiply the digit by its weight and add the resulting products

If the sum is divisible by 11, then it is a valid ISBN number

example: 1-214-02031-3

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

88 is evenly divisible by 11, so the above number is a valid ISBN number

Main function

will input the number from the user into a character array

then call the function checkDigitswill return true

if there are digits

if a correct number of digits in each section

if each section is seperated by a -

otherwise return false

If checkDigits returns true

main will call checkSumwhich will return true

if the sum of the products of the weights and digits is divisible by 11

otherwise return false

main program will output valid or not valid

*Do not use subscripted variables

*Use the pointers to the characters

Declaration for the checkSum

bool checkSum(char *);

*Note: *(ptrISBN +3) is the same as ptrISBN[3]

Check to see if there is an - in the i-th position

use this statement

if(*(ptrISBN + i) == -)

Directions: input ISBN number from user and output "Valid" if the number is valid or Invalid" otherwise. Terminate the input when the user enters "done" ISBN e number for a book 10 digit number made up of 4 sections . each section seperated by Example: ISBN number is: 1-214-02031-3 * 1 represents a country * must be 1 digit 214 represents the publisher e must be 3 digits * 02031 reprsents the book number must be 5 digits * 3 is the checksum * must be 1 digit or the letter'x' checksum is a digit to see if the ISBN number is a valid number * If checksum is 'x' , then that represents the digit 10

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