Array e of ints contains the digits of a number without its check digit. Write code to calculate the check dig?
-
Array e of ints contains the digits of a number without its check digit. Write code to calculate the check digit for this number and store it in checkdigit. The check digit should be such that, if it were inserted after the last digit of e, the result would be the digit array of a number that is valid according to the Luhn algorithm. // Enter values to test here int[] e = { 8,7,6,2 }; int checkdigit; int sum = 0; int dd; for ( int i = 0; i < e.length; i++ ) { /* Your code here */ } checkdigit = /* Your code here */ ; Test case #1 Expected result: checkdigit is 7 // Enter values to test here int[] e = { 5 }; int checkdigit; same code Test case #2 Expected result: checkdigit is 9 // Enter values to test here int[] e = {8,7,6,3}; int checkdigit; same code Test case #3 Expected result: checkdigit is 5 // Enter values to test here int[] e = {3,7,7,2}; int checkdigit; same code Test case #4 Expected result: checkdigit is 1 Thanks!:D
-
Answer:
People here generally prefer to help students who did make an effort to do their homework, rather than just posting the homework here without trying. If you noticed, those who posted their code or asked specific questions are more likely to get a good answer. If you do not even know how to start maybe you should go over your text book and class notes. Then try it on your own. If you cannot get your code to work, post your code here, or ask specific questions such as exactly where you get stuck or what you do not understand. Then someone will be happy to help you. Good luck.
ChrisHug... at Yahoo! Answers Visit the source
Related Q & A:
- How can I convert a string number to a number in Perl?Best solution by Stack Overflow
- How to write code to go through web pages automatically and get the required information?Best solution by Stack Overflow
- How do I check my credit card statement to find my 4 digit-PayPal code?Best solution by Yahoo! Answers
- How do i get my 4-digit PayPal code?Best solution by Yahoo! Answers
- Can you track a package without a tracking number?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.