Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with my ADT Java Program. It is for a credit card. This is the code

ID: 3745649 • Letter: P

Question

Please help with my ADT Java Program. It is for a credit card. This is the code and I keep getting an error saying my Credit Class does not have a main method, where am i going wrong? This is my Java code

public class CreditCard {

//* Error starts here

public static void main(String[], args) {

CreditCard CC1 = new CreditCard("IFlores", 431633445, "3/SEP/2018");

CC1.CreditCharge(100);

CC1.Cash_Adv(300);

CC1.Payment(50);

CC1.InterestAdded(20);
}
}

//* Error ends here

class CCard {

private String CustomerName;

private long AccountNumber;

private String DueDate;

public CCard(String CustomerName, long AccountNumber, String DueDate) {

this.CustomerName = CustomerName;

this.AccountNumber = AccountNumber;

this.DueDate = DueDate;

System.out.println("The Credit Card Details Are ");

System.out.println("Acct Number" + AccountNumber);
System.out.println("Customer Name" + CustomerName);
System.out.println("Due Date" + DueDate);

}

public void CreditCharge(int charge) {
System.out.println("Credit Card has a new Charge of $" + charge);
}

public void Cash_Adv(int C_Adv) {
System.out.println("New Cash Advance issued in the amount of $" + C_Adv);
}

public void Payment(int Amount) {
System.out.println("Thank you for you payment of $" + Amount);
}

public void InterestAdded(int Interest) {
System.out.println("An interest charge of $" + Interest + " has been added to your account");
}

}

Explanation / Answer

The code is perfect except two errors in CreditCard class. Made changes at required places(2 places) and the changes have been in bold.

1)main method has to be like this

public static void main(String[] args)

but the given main method contains comma(,) which is wrong main method

public static void main(String[], args)

2) The below line produces error

CreditCard CC1 = new CreditCard("IFlores", 431633445, "3/SEP/2018");

it shold be

CCard CC1 = new CCard("IFlores", 431633445, "3/SEP/2018");

So the complete code of CreditCard class is:

public class CreditCard

{

public static void main(String[] args)

{

CCard CC1 = new CCard("IFlores", 431633445, "3/SEP/2018");

CC1.CreditCharge(100);

CC1.Cash_Adv(300);

CC1.Payment(50);

CC1.InterestAdded(20);

}

}

Note:There are no changes required in CCard class file.