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

Consider following CreditCard class: package hw.cse214.cc: 2 3 public class Cred

ID: 3885041 • Letter: C

Question

Consider following CreditCard class: package hw.cse214.cc: 2 3 public class CreditCard { 4 private String creditCardNumber: 5 private String cardHolderName: 6 private String bank: 7 private int limit: 8 Q private double balance: 7 10* /* 11 * Constructor 12 */ 13 public CreditCard(String creditCardNumber, String cardHolderName, 14 String bank, int limit, double balance) { 15 this.creditCardNumber - creditCardNumber: 16 this.cardHolderName - cardHolderName: 17 this.bank = bank: 18 this.limit - limit: 19 this.balance - balance: 20 } 21 /* 22 * Aj&tf;&ftC; Methods 23 */ 24 public String getCreditCardNumber() { return creditCardNumber: } 25 public String getCardHolderNameO { return cardHolderName: } 26 public String getBankO { return bank: } 27 public int getLimit() { return limit: } 28 public double getBalance() { return balance;}| 29 30 @Override 31 public String toString() { 32 return "CreditCard [creditCardNumber-" ? creditCardNumber 33 ", cardHolderName-" + cardHolderName ? ", bank-" ? 34 ? ", limit-" + limit + ", balance-" + balance + "]": 35 } 36 } a. Add an action method chargelt (price), which is called on a new transaction. This method takes price as argument and returns whether transaction was successful or not. If the purchase makes the balance exceed the limit, transaction should fail. b. Add an action method payment (amount), which is called when cardholder makes a payment. c. Make necessary changes to add a late fee if payment is done after due date (15th of the month).

Explanation / Answer

ublic static bool PassesLuhnTest(string cardNumber) { //Clean the card number- remove dashes and spaces cardNumber = cardNumber.Replace("-", "").Replace(" ", ""); //Convert card number into digits array int[] digits = new int[cardNumber.Length]; for (int len = 0; len = 0; i--) { int curDigit = digits[i]; if (alt) { curDigit *= 2; if (curDigit > 9) { curDigit -= 9; } } sum += curDigit; alt = !alt; } //If Mod 10 equals 0, the number is good and this will return true return sum % 10 == 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote