Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
  1.  Write a program CheckDigit.java that takes a 12 or 13-digit long as a command-line argument and displays the digit computed as follows:
      • Take for an example the number 048231312622
      • Sum every other digit of the code, starting from the right.  In the example, that is 2 + 6 + 1 + 1 + 2 + 4 = 16.  Discard the tens digit and keep the ones digit, 6. 
      • Start with the second to last digit and do the same thing.  Sum the digits, discard the tens digit and keep the ones digit.  In this example this is 2 + 2 + 3 + 3 + 8 + 0=18.  Discarding the 10 leaves 8.  Multiply this number by 3 and again discard the tens digit.  8×3 = 24, leaving 4.
      • Add the numbers from steps 1 and 2.  Again drop the tens digit.  6 + 4 = 10, leaving the digit 0 (zero).
      • Hint 1: the maximum value that can be stored in an integer variable is 2147483647 which is only 10 digits long. To read a 12 or 13-digit integer from command line argument you will need to store it in a long variable. Use: long number = Long.parseLong(args[0]); to read a long from the command line.
      • Hint 2: to extract the rightmost digit of a number use the modulus operator.
      • Hint 3: to remove the rightmost digit of a number use the integer division by 10
      • Hint 4: for full credit use a loop to compute the sums
    • Assume the input value used to test your program is a 12 or 13-digit positive integer. 

 

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education