Hjælp til en programmeringsopgave!!
Har en opgave der lyder som følgende:Check-digits are used to check whether a number is correctly entered by a user (for example a bank account number or CPR-number). By using check digits many but not all errors can be found. The check digit is added the original number such that the test can be easily performed. We describe an algorithm below. The number is given as string and the check digit is already added.
Let xn-1xn-2 ..... x2x1x0, be an n-digit decimal number, that is xi  ; (0,1; 2; 3; 4; 5; 6; 7; 8; 9), for all i. The algorithm replaces every digit with an odd index by twice the digit if that is less then 10. If twice the digit is 10 or larger then take the modulus with respect to
10 and add 1. That is, 2 is replaced 4, 7 by 5 = (14 mod 10) + 1. Then all the digits of the resulting number are summed up, i.e. the cross sum is computed. If that sum has remainder 0 modulo 10 the number is accepted, otherwise not. The digits with an even index are not changed.
Write a class NumberCheck which contains a method:
public static boolean check (String number )
which returns true if the number is accepted and false otherwise. Use exactly the names specified above for the class and method. For example, the number 3475 becomes 6455 after replacement of the odd-indexed digits and is accepted by the program because the cross sum of 6455 is 20 and 0 = 20 mod 10.
The number 41032 is rejected.
You may assume that the string number only contains decimal digits; you do not have to check that.
Her er den foreløbige kode, som jeg har skrevet:
package aflop01_12;
public class NumberCheck {
public static boolean check (String string){
int i = 100;
if (i >= 10 && i<=99 && (i / 10 !=i % 10)){
return true;
} else{
return true;
}
}
}
Håber jeg kan få hjælp til opgaven