IN JAVA PLEASE Design and implement an ADT CreditCard that represents a credit card. The data of the ADT should include Java variables for the customer name, the account number, the next due date, the reward points, and the account balance. The initialization operation should set the data to client-supplied values. Include operations for a credit card charge, a cash advance, a payment, the addition of interest to the balance, and the display of the statistics of the account. Be sure to include a main class which creates an object from your CreditCard class.
I would really apreciate if you can walk me through it and provide me a full soluition of how to implement the code. Everything is stated in the question
Here is what I have so far I get a blank when I run the program...
public interface CreditCard {
public static void main(String[] args) {
}
String name = "";
String accountNumber = "";
String dueDate = "";
int rewardPoints = 0;
double accountBlance = 0.0;
public boolean inputCreditCard(String name, String accountNumber);
public boolean chargeCreditCard(String accountNumber, double charge);
public boolean getCashAdvance(String accountNumber, double advance);
public boolean submitPayment(String accountNumber, double payment);
public double combineIntrest(String accountNumber);
public void displayStatistics(String accountNumber);
}
import java.util.Scanner;
import javax.swing.*;
import java.awt.*;
import java.net.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.IOException;
public class creditCard {
private int customerName;
private int accountNumber;
private int dueDate;
private int rewardPoints;
private int accountBalance;
static Scanner input = new Scanner(System.in);
double creditLimit = 500;
int user = 0;
public int getCustomerName() {
return customerName;
}
public void setCustomerName(int customerName) {
this.customerName = customerName;
}
public int getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public int getDueDate() {
return dueDate;
}
public void setDueDate(int dueDate) {
this.dueDate = dueDate;
}
public int getRewardPoints() {
return rewardPoints;
}
public void setRewardPoints(int rewardPoints) {
this.rewardPoints = rewardPoints;
}
public int getAccountBalance() {
return accountBalance;
}
public void setAccountBalance(int accountBalance) {
this.accountBalance = accountBalance;
}
public String charge(float amount) {
if (amount > creditLimit) {
System.out.println("You have exceeded your credit card limit and no charge can be made");
}
if (creditLimit - amount > 0) {
System.out.println("You have exceeded your credit card limit and no charge can be made");
}
creditLimit = creditLimit - amount;
System.out.println("A charge of" + amount + "has been made.");
String charge = "A charge of" + amount + "has been made.";
return charge;
}
public String advance(float amount) {
if (amount > creditLimit) {
System.out.println("You have exceeded your credit card limit and no charge can be made");
}
if (creditLimit - amount > 0) {
System.out.println("You have exceeded your credit card limit and no charge can be made");
}
creditLimit = creditLimit - amount;
System.out.println("You have withdrawn $ " + amount);
String advance = "You have withdrawn $ " + amount;
return advance;
}
public String payment(float amount) {
creditLimit = creditLimit + amount;
System.out.println("You have a credit limit of $ " + creditLimit);
String payment = "You have a credit limit of $ " + creditLimit;
return payment;
}
public String interest() {
creditLimit = (creditLimit * 0.02) + creditLimit;
String interest = "An interest of" + creditLimit * 0.02 + "has been added to your balance";
return interest;
}
public void statistics(String charge, String advance, String payment, String interest) {
System.out.println(charge);
System.out.println(advance);
System.out.println(payment);
System.out.println(interest);
}
public void showMenu() {
while (user!= 5) {
System.out.println("Choose Charge(1) \nAdvance(2) \nPayment(3) \nInterest(4) \ncStatistics(5)");
user = input.nextInt();
switch (user) {
case 1:
float amount;
System.out.println("Enter the amount: ");
amount = input.nextFloat();
String charge = charge(amount);
break;
case 2:
float withdrawalAmount;
System.out.println("Enter amount to withdraw: ");
withdrawalAmount = input.nextFloat();
String advance = advance(withdrawalAmount);
break;
case 3:
float paymentAmount;
System.out.println("Enter payment.");
paymentAmount = input.nextFloat();
String payment = payment(paymentAmount);
break;
case 4:
String interest = interest();
break;
//case 5:
//statistics(charge, advance, payment, interest);
//break;
}
}
}
public class Runner {
public static void main(String[] args) {
CreditCard creditCard= new CreditCard();
creditCard.showMenu();
// Do something else
}
Get Answers For Free
Most questions answered within 1 hours.