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
Law Incorporation [45]
3 years ago
13

The following checksum formula is widely used by banks and credit card companies to validate legal account numbers: d0 + f(d1) +

d2 + f(d3) + d4 + f(d5) + . . . = 0 (mod 10) The di are the decimal digits of the account number and f(d) is the sum of the decimal digits of 2d (for example, f(7) = 5 because 2 x 7 = 14, and 1 + 4 = 5). For example, 17327 is valid because 1 + 5 + 3 + 4 + 7 = 20, which is a multiple of 10. Implement the function f and write a program to take a 10-digit integer as a command line argument and print a valid 11-digit number with the given integer as its first 10 digits and the checksum as the last digit. Check that when applying the formula to the 11-digit number, the result after mod 10 is 0.
Computers and Technology
1 answer:
Aleksandr [31]3 years ago
8 0

Answer:

Here is the JAVA program:

import java.util.Scanner; //to import Scanner class

public class ISBN

{   public static void main(String[] args)  { // start of main() function body

   Scanner s = new Scanner(System.in); // creates Scanner object

//prompts the user to enter 10 digit integer

   System.out.println("Enter the digits of an ISBN as integer: ");    

   String number = s.next(); // reads the number from the user

   int sum = 0; // stores the sum of the digits

   for (int i = 2; i <= number.length(); i++) {

//loop starts and continues till the end of the number is reached by i

          sum += (i * number.charAt(i - 1) ); }

/*this statement multiplies each digit of the number with i and adds the value of sum to the product result and stores in the sum variable*/

          int remainder = (sum % 11);  // take mod of sum by 11 to get checksum  

   if (remainder == 10)

/*if remainder is equal to 10 adds X at the end of given isbn number as checksum value */

  { System.out.println("The ISBN number is " + number + "X"); }

  else

// displays input number with the checksum value computed

 {System.out.println("The ISBN number is " + number + remainder); }  }  }  

Explanation:

This program takes a 10-digit integer as a command line argument and uses Scanner class to accept input from the user.

The for loop has a variable i that starts from 2 and the loop terminates when the value of i exceeds 10 and this loop multiplies each digit of the input number with the i and this product is added and stored in variable sum. charAt() function is used to return a char value at i-1.

This is done in the following way: suppose d represents each digit:

sum=d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9

Next the mod operator is used to get the remainder by dividing the value of sum with 11 in order to find the checksum and stores the result in remainder variable.

If the value of remainder is equal to 10 then use X for 10 and the output will be the 10 digits and the 11th digit checksum (last digit) is X.

If the value of remainder is not equal to 10, then it prints a valid 11-digit number with the given integer as its first 10 digits and the checksum computed by sum % 11 as the last digit.  

You might be interested in
A(n ______ allows a user to specify a task without specifying how the task will be accomplished
Goshia [24]
The answer is: a query language


Hope that helped :)
6 0
3 years ago
A___________is a collection of computer software, typically malicious, designed to enable access to a computer or an area of its
Molodets [167]

Answer: rootkit

Explanation:

Hi, A rootkit is a collection of computer software, typically malicious, designed to enable access to a computer or an area of its software that is not otherwise allowed (for example, to an unauthorized user) and often masks its existence or the existence of other software.

A rootkit provides continued privileged access to a computer while hiding its presence. Because of this hiding characteristic it is very difficult to detect.

Once a rootkit has been installed, it allows someone to have total remote control of a computer and do things such as files executions and system changes.

4 0
3 years ago
Polaroid had a unique competitive advantage for many years until it forgot to observe competitive intelligence. The firm went ba
Snowcat [4.5K]

Answer:

false

Explanation:

Based on the information provided within the question it can be said that the statement being made is false. This statement does not exemplify Porter's threat of new entrants, since this talks about the threat of new companies entering the same market with the same product in order to compete with the existing competitors in that market. In this scenario the new companies that eventually made Polaroid Bankrupt had an innovative new technology and which people starting using and left the entire Polaroid Market behind.

8 0
3 years ago
This type of connection uses radio waves to connect devices on a network.
Tresset [83]
I believe data carries radio waves
5 0
4 years ago
Read 2 more answers
What project started the development of inter-network connections using tcp/ip that has evolved into the internet today.?
rosijanka [135]
Dial Up, help start it
3 0
4 years ago
Other questions:
  • Cleaning the keyboard is the most important part of keeping your computer running at peak performance.
    5·2 answers
  • Identify the parts used in an electric circuit- Tiles
    9·2 answers
  • I can't see the answer
    13·2 answers
  • 5. What are the two main functions performed by UPS​
    12·1 answer
  • Which option allows you to view slides on the full computer screen?
    11·1 answer
  • A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Ab
    11·1 answer
  • Files exist on ____ storage devices, such as hard disks, dvds, usb drives, and reels of magnetic tape.
    11·1 answer
  • Julie has a difficult time seeing her computer Screen and uses adaplive technology tools to help he see better. One of the tools
    13·2 answers
  • Which of the following screen elements is a horizontal bar that displays at the
    8·1 answer
  • What level of system and network is required for cui
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!