c++  use do while/for loops please dont use string and bool

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

c++ 
use do while/for loops

please dont use string and bool

E.
Test Data:
Test Case Number
1
2
3
ISBN
0-07-021604-5
0-07-201604-5
0-534-37130-2
Valid Or Invalid
Valid
Invalid
Valid
Transcribed Image Text:E. Test Data: Test Case Number 1 2 3 ISBN 0-07-021604-5 0-07-201604-5 0-534-37130-2 Valid Or Invalid Valid Invalid Valid
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
An international standard book number (ISBN) is used to uniquely identify a book.
It is made of 10 digits, as shown here:
0
The country
The publisher
Write a program that tests an ISBN to see if it is valid.
a.
a.
b.
b.
The tenth digit may be x, which indicates 10.
To determine the weighted sum, the value of each position is multiplied by its relative position,
starting from the right, and the sum of the products is determined.
The callation of the weighted sum for the ISBN shown above is shown in the following table:
Weighted Sum Calculation
Weight
a.
For an ISBN number to be valid, the weighted sum of the 10 digits must be evenly
divisible by 11.
Code
b.
Output:
a.
b.
0
0
7
0
2
1
6
0
4
5
Additional Processing:
Full ISBN: 0-07-021604-5
07
10
9
8
7
6
5
4
3
2
1
Weighted
Value
Weighted Sum: 110
Since the weighted sum modulus 11 is zero, the ISBN number is valid.
The program should validate the input with the following:
That a 10 digit number has been entered.
That none of the numbers entered are negative.
021604
The book number
0
0
56
0
12
5
24
0
8
5
5
The check digit
A loop should be built so that the program can process an unknown quantity of ISBN
validations until the user enters a response that they no longer wish to process another ISBN.
Use a loop that is within the prior described loop to process each character of the ISBN.
A heading explaining the contents of the output.
Display one line per test case containing the ISBN and whether the ISBN is valid or
invalid.
Transcribed Image Text:1. 2. 3. 4. 5. 6. 7. 8. 9. 10. An international standard book number (ISBN) is used to uniquely identify a book. It is made of 10 digits, as shown here: 0 The country The publisher Write a program that tests an ISBN to see if it is valid. a. a. b. b. The tenth digit may be x, which indicates 10. To determine the weighted sum, the value of each position is multiplied by its relative position, starting from the right, and the sum of the products is determined. The callation of the weighted sum for the ISBN shown above is shown in the following table: Weighted Sum Calculation Weight a. For an ISBN number to be valid, the weighted sum of the 10 digits must be evenly divisible by 11. Code b. Output: a. b. 0 0 7 0 2 1 6 0 4 5 Additional Processing: Full ISBN: 0-07-021604-5 07 10 9 8 7 6 5 4 3 2 1 Weighted Value Weighted Sum: 110 Since the weighted sum modulus 11 is zero, the ISBN number is valid. The program should validate the input with the following: That a 10 digit number has been entered. That none of the numbers entered are negative. 021604 The book number 0 0 56 0 12 5 24 0 8 5 5 The check digit A loop should be built so that the program can process an unknown quantity of ISBN validations until the user enters a response that they no longer wish to process another ISBN. Use a loop that is within the prior described loop to process each character of the ISBN. A heading explaining the contents of the output. Display one line per test case containing the ISBN and whether the ISBN is valid or invalid.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

can u do it without using string

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning