1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
satela [25.4K]
3 years ago
12

python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. T

he last digit, d10, is a checksum, which is calculated from the other nine digits using the following formula: (d1 * 1 d2 * 2 d3 * 3 d4 * 4 d5 * 5 d6 * 6 d7 * 7 d8 * 8 d9 * 9) % 11 If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros). Sample Run 1 Enter the first 9 digits of an ISBN as a string: 3601267 Incorrect input. It must have exact 9 digits Sample Run 2 Enter the first 9 digits of an ISBN as a string: 013601267 The ISBN-10 number is 0136012671 Sample Run 3 Enter the first 9 digits of an ISBN as a string: 013031997 The ISBN-10 number is 013031997X
Computers and Technology
1 answer:
iogann1982 [59]3 years ago
5 0

Answer:

<em>The programming language is not stated;</em>

<em>However, I'll answer this question using C++ programming language</em>

<em>The program uses few comments; See explanation section for more detail</em>

<em>Also, the program assumes that all input will always be an integer</em>

#include<iostream>

#include<sstream>

#include<string>

using namespace std;

int main()

{

string input;

cout<<"Enter the first 9 digits of an ISBN as a string: ";

cin>>input;

//Check length

if(input.length() != 9)

{

 cout<<"Invalid input\nLength must be exact 9";

}

else

{

 int num = 0;

//Calculate sum of products

for(int i=0;i<9;i++)

{

 num += (input[i]-'0') * (i+1);    

}

//Determine checksum

if(num%11==10)

{

 input += "X";

 cout<<"The ISBN-10 number is "<<input;

}

else

{

 ostringstream ss;

 ss<<num%11;

 string dig = ss.str();

 cout<<"The ISBN-10 number is "<<input+dig;

}

}  

 return 0;

}

Explanation:

string input;  -> This line declares user input as string

cout<<"Enter the first 9 digits of an ISBN as a string: ";  -> This line prompts the user for input

cin>>input;  -> The user input is stored here

if(input.length() != 9)  { cout<<"Invalid input\nLength must be exact 9";  }  -> Here, the length of input string is checked; If it's not equal to then, a message will be displayed to the screen

If otherwise, the following code segment is executed

else  {

int num = 0; -> The sum of products  of individual digit is initialized to 0

The sum of products  of individual digit is calculated as follows

for(int i=0;i<9;i++)

{

num += (input[i]-'0') * (i+1);

}

The next lines of code checks if the remainder of the above calculations divided by 11 is 10;

If Yes, X is added as a suffix to the user input

Otherwise, the remainder number is added as a suffix to the user input

if(num%11==10)  {  input += "X";  cout<<"The ISBN-10 number is "<<input; }

else

{

ostringstream ss;

ss<<num%11;

string dig = ss.str();

cout<<"The ISBN-10 number is "<<input+dig;

}

}  

You might be interested in
Tech A states that modern vehicles use asbestos as the brake material. Tech B states that asbestos is no longer used in brakes.
Tanya [424]

Answer:

Tech A is correct.

Explanation:

The modern day vehicles have brakes system equipped with asbestos. It is a mineral which is a kind of fibrous crystal which enables the friction to stop the vehicle. The technician A specifies that the modern day automobiles use asbestos for their brake system.

4 0
2 years ago
Write a function that takes an integer value and returns the number with its digits reversed. for example, given the number 7631
lesantik [10]

//=indicating you to do the programming part on your own relating to the description provided against. This done because different programming languages require different coding for that.

n=integer value

n1=dummy storage for n

r=variable used to do the function

{

int n,r,n1,rev=0;

//do the coding here for storing the integer in the variable n

n1=n;

while(n>0){

   r=n%10;

   rev=(rev*10)+r;

   n=n/10;

   }

//now add a command for displaying the value of rev

}

this is just a logic i used for java

done.

3 0
2 years ago
Select the best answer from the drop-down menu.
maw [93]

Answer:

1) performance assessments

2) measurable goals

3)can't be measured quantitatively

4) milestones

Explanation:

Methods of evaluating the performance and productivity of an individual or group in relation to predetermined criteria and measurable goals are <u>performance assessments.</u>

<u>measurable goals</u> are goals that have concrete criteria for measuring progress toward their attainment.

Why are statements like “great customer experience” or “more sales” not good assessment criteria? <u>can't be measured quantitatively</u>

Personal goal setting helps lagging performance by setting <u>milestones</u>

which are short-term achievable tasks.

<u>OAmalOHopeO</u>

8 0
2 years ago
Read 2 more answers
What is the purpose of the making of Nintendo Switch?
Elden [556K]

Answer:

To create a console that is suitable for children and families.

7 0
3 years ago
Read 2 more answers
Award documentation is typically required to be prepared and submitted within how long after the end of a project period:_____.
Stella [2.4K]

Award documentation is typically required to be prepared and submitted within how long after the end of a project period of 90 days.

What does Award includes?

  • Awards to international organizations and government institutions, whether or whether they are covered by SNAP, must include annual expenditure information.
  • The report shall be submitted for each budget period, if necessary on an annual basis, no later than 90 days following the end of the calendar quarter in which the budget period concluded.
  • The report must include information on any allowed extensions to the budgetary period. If more regular reporting is necessary, both the frequency and the deadline shall be stated in the NoA.

Learn more about the Post-Award Monitoring and Reporting with the help of the given link:

brainly.com/question/15415195

#SPJ4

5 0
1 year ago
Other questions:
  • Which computing component is similar to the human brain
    6·2 answers
  • To gain one pound of fat, how many extra calories would you need to consume?
    12·1 answer
  • Look at the following form. Which input method is the form using to receive the user's favorite activity? What is your favorite
    12·2 answers
  • . char values are surrounded by _____ quotes
    15·1 answer
  • _____ remove the part of an image starting from an edge​
    13·1 answer
  • How is kerning used in Word?
    7·2 answers
  • To insert text from a separate file into your Word document
    10·1 answer
  • 334. Universal Containers uses a custom field on the account object to capture the account credit status. The sales team wants t
    12·1 answer
  • (Count the occurrences of words in a text file) Rewrite Listing 21.9 to read the text from a text file. The text file is passed
    10·1 answer
  • How does the sky change as onegets above Earth’s atmosphere?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!