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
USPshnik [31]
3 years ago
9

ISBN-13 is a new standard for identifying books. It uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d12d13. The last digit d13 is a check

sum, which is calculated from the other digits using the following formula: 10 - (d1 3d2 d3 3d4 d5 3d6 d7 3d8 d9 3d10 d11 3d12) % 10 If the checksum is 10, replace it with 0. Your program should read the input as a string.

Computers and Technology
1 answer:
qwelly [4]3 years ago
5 0

Answer:

// Scanner class is imported to allow program

// read input from user

import java.util.Scanner;

// Solution class is created

public class Solution {

// main method that begin program execution

public static void main(String[] strings) {

// Scanner object scan is created

// it receive input via the keyboard

Scanner scan = new Scanner(System.in);

// a prompt is displayed for user to enter 12 digits of ISBN

System.out.print("Enter the first 12 digits of an ISBN as string: ");

// user input is assigned to input

String input = scan.next();

//if length of input is not 12, program display error message and quit

if (input.length() != 12) {

System.out.println(input + " is Invalid input");

System.exit(0);

}

// 0 is assigned to checkSum

int checkSum = 0;

// for loop that goes through the string and does the computation

for (int i = 0; i < input.length(); i++) {

// if the index is even

if ((i + 1) % 2 == 0) {

checkSum += (input.charAt(i) - '0') * 3;

}

// if the index is odd

else

{

checkSum += input.charAt(i) - '0';

}

}

// modulo 10 of checkSum is assigned to checkSum

checkSum %= 10;

// checkSum is substracted from 10

checkSum = 10 - checkSum;

// if checkSum equals 10, 0 is concatenated with input

// else input is concatenated with checkSum

if (checkSum == 10) input += "0";

else input += checkSum;

// the new value of the isbn-13 is displayed

System.out.println("The ISBN-13 number is " + input);

}

}

Explanation:

The program is written in Java and well commented.

A sample of program output during execution is also attached.

You might be interested in
Rewrite the Espresso Counter program to Swap or interchange any two rows of the output. Copy and paste just the interchanged par
seraphim [82]

Answer:

Rewrite the Espresso Counter program to Swap or interchange any two rows of the output. Copy and paste just the interchanged parts of the code. Compile and run the modified program. Copy and paste the new user interface output. Add a new row to the Espresso Counter user interface. Describe your modifications. Compile and run the new program. Copy and paste

1. Your modifications

2. Snapshots of your new counter interface.

4 0
2 years ago
What's the full form of CPU?​
Bas_tet [7]

Answer:

Central processing unit

5 0
3 years ago
Read 2 more answers
A food web is shown below. In this food web, energy is transferred directly from the to the
Irina18 [472]

That answer would be the producer

8 0
3 years ago
Please Help!<br><br>in return brainliest and special thanks
arlik [135]
1. Option 3
2. Option 2
3. Option 3
8 0
3 years ago
Which of the following definition below describes a wall opening?
My name is Ann [436]
A. An opening at least 30 inches high and 18 inches wide in any wall or partition. 
5 0
3 years ago
Read 2 more answers
Other questions:
  • A(n) ________ signal is a discrete, binary waveform that transmits data coded into two discrete states such as 1-bits and 0-bits
    12·1 answer
  • Okay so, not really a question but whatever it’s been bothering me.
    9·2 answers
  • Instructions Write a program that asks the user for a number. If the number is between 1 and 255, the program outputs the corres
    15·1 answer
  • What is a Better Computer?<br> A. Alien<br> B. Microsoft<br> C. Windows<br> D. Apple
    11·2 answers
  • What do you need for digital photography? 1. 2. 3.
    13·1 answer
  • Why are mobile phone called cell phones?​
    13·1 answer
  • Write an algorithm that accepts two numbers,
    7·1 answer
  • Please list 15 safety rules that you think should be practiced in the Computer Technology classroom/lab.
    12·1 answer
  • The type value ____ for the input element may cause modern browsers to validate entries to ensure that they are valid web addres
    14·1 answer
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. please select the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!