I'm recieving a ton of errors on my Java doc for an assignment I have can anyone help me fix them?
I'm recieving a ton of errors on my Java doc for an assignment I have can anyone help me fix them?
code:
package chapter.pkg6.part.pkg2.assignment;
/**
*
* @author matty
*/
public class Chapter6Part2Assignment {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Method
long cardnumber = 4440967484181607L;
System.out.println("Please enter the card number/n");
System.out.println(cardnumber + " is " + (validitychk(cardnumber) ? "valid" : "invalid"));
// Return true if the card number is valid
public static boolean validitychk(long cnumber) {
return (thesize(cardnumber)>=13&& thesize(cnumber)<= 16)&&(prefixmatch(cardnumber, 4)
|| prefixmatch(cardnumber,5) || prefixmatch(cnumber,37) || prefixmatch(cardnumber, 6))
&& ((sumdoubleeven(cnumber) + sumodd(cnumber)) % 10 == 0);
}
public static int sumdoubleeven(long cardnumber) {
int sum = 0;
String num = cardnumber + "";
for (int i = thesize(cardnumber) - 2; i >= 0; i -= 2)
sum += getDigit(Integer.parseInt(num.charAt(i) + "") * 2);
return sum;
}
public static int getDigit(int cardnumber) {
if (cardnumber < 9)
return cardnumber;
return cardnumber / 10 + cardnumber % 10;
}
public static int sumodd(long cardnumber) {
int sum = 0;
String num = cardnumber + "";
for (int i = thesize(cardnumber) - 1; i >= 0; i -= 2)
sum += Integer.parseInt(num.charAt(i) + "");
return sum;
}
}
I attached an image of the code and the error issue as well.
![### Java Program for Credit Card Validation
This code is a Java program used to validate a credit card number. It uses Luhn's algorithm, which involves checking the size and prefix of the card number.
#### Code Explanation
```java
/**
* Author: [Author Name]
* Param: args the command line arguments
*/
public class Chapter6Part2Assignment {
// Main method
public static void main(String[] args) {
long cardnumber = 4410976841816071L;
System.out.println("Please enter the card number:\n");
System.out.println(cardnumber + " is " + (validitychk(cardnumber) ? "valid" : "invalid"));
// Return true if the card number is valid
}
public static boolean validitychk(long cnumber) {
return (thesize(cnumber) >= 13 && thesize(cnumber) <= 16) && (prefixmatch(cnumber, 4)
|| prefixmatch(cnumber, 5) || prefixmatch(cnumber, 6) || prefixmatch(cnumber, 37))
&& ((sumdoubleeven(cnumber) + sumodd(cnumber)) % 10 == 0);
}
public static int sumdoubleeven(long cardnumber) {
int sum = 0;
String num = cardnumber + "";
for (int i = thesize(cardnumber) - 2; i >= 0; i -= 2) {
sum += getDigit(Integer.parseInt(num.charAt(i) + "") * 2);
}
return sum;
}
public static int getDigit(int cardnumber) {
if (cardnumber < 9)
return cardnumber;
return cardnumber / 10 + cardnumber % 10;
}
public static int sumodd(long cardnumber) {
int sum = 0;
String num = cardnumber + "";
for (int i = thesize(cardnumber) - 1; i >= 0; i -= 2)
sum += Integer.parseInt(num.charAt(i) + "");
return sum;
}
public static boolean prefixmatch(long cardnumber, int d) {
return getprefix(cardnumber, thesize(d)) == d;
}
public static int thesize(long d) {
String num = d + "";
return num.length();](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe73c8c7e-1fd5-4385-96bf-6506c467a37a%2Fc1e44586-57f1-4580-8ee0-9225311403c9%2F6kyby6w_processed.png&w=3840&q=75)


Step by step
Solved in 3 steps with 4 images









