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]
2 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]2 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
JavaScript
Mekhanik [1.2K]

Answer:

C. 40

Explanation:

The code uses IF and ELSE statements to carry execute a block of code if any of the statements hold true

OrderTotal here is greater than 100, and this allows the second IF ELSE block to be executed.

The code to be executed is discountAmount = OrderTotal * 0.2

This will be discountAmount = 200 *0.2

therefore, discountAmount = 40.

3 0
3 years ago
The set of coordinating colors applied to backgrounds, objects, and text in a presentation is called:
Sonja [21]

Answer:

theme colors

Explanation:

As said, a group of colors that are used to format text and objects in a document. When you open the Color menu, these colors determine what you see.

3 0
2 years ago
How to delete account on this
qwelly [4]

Answer:

Explanation:

Go and edit your profile then go on prefernces you will see that its written delete my account and that's how you delete your account on brainly.com and if you want to delete you account on phone then

Open your phone's Settings app.

Tap Accounts. If you don't see "Accounts," tap Users & accounts.

Tap the account you want to remove Remove account.

If this is the only Google Account on the phone, you'll need to enter your phone's pattern, PIN, or password for security.

Hope this helped you!

5 0
2 years ago
Read 2 more answers
You decide to bulk upload your multiple business locations to Google My Business. Some of the locations in your upload were disa
koban [17]

Complete Question: You decide to bulk upload your multiple business locations to Google My Business. Some of the locations in your upload were disapproved. Which two errors can cause this issue? (Choose two.)

A    Missing listing photos

B  Late listing registration

C   Multiple locations in one physical address

D  Too many listing users

E  Incorrect business name

Answer:

C) Multiple locations in one physical address

E) Incorrect business name

Explanation:

Google provides a service called Google My Business which allows users  with the aid of special tools create, update and maintain their business profiles on the internet. In this way, users are able to build free simple websites and publish posts to engage their customers more effectively.

In the process of signing up for this service, new users are required to verify their business names and physical locations, In the given question a user trying to upload multiple business locations will not get approval if he uploads Multiple locations in one physical address or enters an Incorrect business name.

4 0
3 years ago
Why should computers have a file structure? For organization For storing code To prevent viruses To keep back-ups of files
AURORKA [14]

Answer: I believe the answer to your question is  For organization I hope this helps!  

8 0
2 years ago
Other questions:
  • Implement the function calcWordFrequencies() that uses a single prompt to read a list of words (separated by spaces). Then, the
    8·1 answer
  • Which of the following is a category of social media?
    8·2 answers
  • Jennifer frequently uses a few programs on her laptop. Where will she find all the frequently used program icons in her computer
    13·1 answer
  • ____ devices are high-performance storage systems that are connected individually to a network to provide storage for the comput
    12·1 answer
  • Managing your calendar and emails can be easily accomplished through ___ software
    8·1 answer
  • When specifying keywords to conduct an internet search, which of the following parts of speech will be the most useful??
    6·1 answer
  • EX 3.8 Write code to declare and instantiate an object of the Random class (call the object reference variable rand). Then write
    6·1 answer
  • Given the following while() loop, which statement is true assuming A,B,C,D are int variables and A &gt; B? while ( ( A &gt;= B)
    8·1 answer
  • What’s an example of software?
    6·2 answers
  • The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and eac
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!