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

Part C: Credit Cards Problem Description: In this question, you will write a cla

ID: 3907467 • Letter: P

Question

Part C: Credit Cards Problem Description: In this question, you will write a class to represent a credit card. The class details are as follows: 1. Static Variables a. baseRate The minimum interest rate that the card can have. This should be a constant that is hard coded. b. lastAccountNumber- The last account number assigned to a customer. Account numbers should be assigned sequentially. 2. Instance Variables a. accountholder The name of the person who owns the card. b. accountNumber - A unique 7-digit identifier number. c. creditScore The account holder's credit score, d. rate The annual interest rate charged to the card. e. balance The current balance on the card. f creditLimit - The card holder's credit limit. 3, Methods

Explanation / Answer


import java.util.Scanner;

class CreditCard{

private static int baseRate=5;
private static long lastAccountNumber=3456780;
private String accountholder;
private long accountNumber;
public double balance;
private int creditScore,rate,creditLimit;
CreditCard(String an,int c){
accountNumber = lastAccountNumber;
lastAccountNumber++;
accountholder = an;
creditScore = c;
balance = 0;
if(c<300){
rate = baseRate+10;
creditLimit = 1000;
}
else if(c>300 && c<500){
rate = baseRate+7;
creditLimit = 3000;
}
else if(c>500 && c<700){
rate = baseRate+4;
creditLimit = 7000;
}
else{
rate = baseRate+1;
creditLimit = 15000;
}
}
public void makePurchase(double amount){
if(amount+balance > creditLimit){
balance = balance+amount;
}
}
public void makePayment(double amount){
if(amount > balance){
balance =0 ;
creditScore = creditScore+10;
int c = creditScore;
if(c<=300){
rate = baseRate+10;
creditLimit = 1000;
}
else if(c>300 && c<=500){
rate = baseRate+7;
creditLimit = 3000;
}
else if(c>500 && c<=700){
rate = baseRate+4;
creditLimit = 7000;
}
else{
rate = baseRate+1;
creditLimit = 15000;
}
  
}
else if( amount < 0.1*balance){
balance = balance-amount;
raiseRate(1);
}
}
public void raiseRate(int n){
rate = rate+n;
}
public void raiseLimit(int n){
creditLimit = creditLimit+n;
}
public void calculateBalance(){
balance = balance + (balance*rate)/12;
}
public void tostring(){
System.out.println(accountholder + " xxxx" +(accountNumber %1000) + " " + balance +" "+ creditLimit);
}
}

public class HelloWorld{

public static void main(String []args){
Scanner sc = new Scanner(System.in);
CreditCard c = new CreditCard("John", 300);
c.makePurchase(800);
for(int i=1;i<=6;i++){
System.out.println("Do you want to pay? if yes then press 1 else 0:");
int l = sc.nextInt();
if(l==1){
System.out.println("Enter the amount:");
c.makePayment(sc.nextInt());
}
else{
c.raiseRate(2);
}
}
c.tostring();
}
}

//The above code has the operations class

Modify the main funtion if neede.

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