Question

IN JAVA PLEASE Design and implement an ADT CreditCard that represents a credit card. The data...

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);

}

Homework Answers

Answer #1

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

   }

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am writing code in java to make the design below. :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) I already have...
I am writing code in java to make the design below. :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) I already have this much public class Main { int WIDTH = 0; double HEIGHT = 0; public static void drawSmileyFaces() { System.out.println(" :-):-):-):-):-):-)"); } public static void main (String[] args) { for (int WIDTH = 0; WIDTH < 3; WIDTH++ ) { for(double HEIGHT = 0; HEIGHT < 2; HEIGHT++) { drawSmileyFaces(); } } } } I am pretty sure that alot of this is wrong...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with the default values denoted by dataType name : defaultValue - String animal : empty string - int lapsRan : 0 - boolean resting : false - boolean eating : false - double energy : 100.00 For the animal property implement both getter/setter methods. For all other properties implement ONLY a getter method Now implement the following constructors: 1. Constructor 1 – accepts a String...
[Java] I'm not sure how to implement the code. Please check my code at the bottom....
[Java] I'm not sure how to implement the code. Please check my code at the bottom. In this problem you will write several static methods to work with arrays and ArrayLists. Remember that a static method does not work on the instance variables of the class. All the data needed is provided in the parameters. Call the class Util. Notice how the methods are invoked in UtilTester. public static int min(int[] array) gets the minimum value in the array public...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*;...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*; import javax.swing.*; public class Clicker extends JFrame implements ActionListener {     int count;     JButton button;     Clicker() {         super("Click Me");         button = new JButton(String.valueOf(count));         add(button);         button.addActionListener(this);         setSize(200,100);         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         setVisible(true);     }     public void actionPerformed(ActionEvent e) {         count++;         button.setText(String.valueOf(count));     }     public static void main(String[] args) { new Clicker(); } } a. add(button);...
is there anything wrong with the solution. the question are from java course Write a main...
is there anything wrong with the solution. the question are from java course Write a main method that will request the user to enter Strings using a JOptionPane input dialog. The method should continue accepting strings until the user types “STOP”.       Then, using a JOptionPane message dialog, tell the user how many of the strings begin and end with a digit. Answer: import javax.swing.*; public class IsAllLetters {     public static void main(String[] args) {         String input;         int count =...
Using Java, please implement the Poker and PokerHand classes to provide the expected output using the...
Using Java, please implement the Poker and PokerHand classes to provide the expected output using the CardDemo class. Rules are the following: - Deck and PockerHand should be Iterable (note that you may just reuse one of the underlying iterators to provide this functionality) - Poker should implement 2 methods checking for two possible poker hands , see the comments inside the classes for details. Hint: remember how one can count the frequency of words in text? - whenever you...
IN JAVA Complete the following program. Add codes in the main method to:1) call method average(double[]...
IN JAVA Complete the following program. Add codes in the main method to:1) call method average(double[] gpaarr ) to calculate the average of gpaArray; 2) add codes in the for loop to calculate sum 3) print the average . public class Test { public static void main (String args[]) { double[ ] gpaArray = { 2.5, 4.0, 3.8, 3.2, 2.9, 4.0 } ;   //add your codes here (you can put your codes in the Answer area with/without copying the original...
Whenever I try to run this program a window appears with Class not Found in Main...
Whenever I try to run this program a window appears with Class not Found in Main project. Thanks in Advance. * * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Assignment10; /** * * @author goodf */ public class Assignment10{ public class SimpleGeometricObject { private String color = "white"; private boolean filled; private java.util.Date dateCreated;    /**...
I am having some trouble writing some java code involving strings. I have included the code...
I am having some trouble writing some java code involving strings. I have included the code provided by my professor below. that has the instructions in it as well public class StringExercise { public static void main(String[] args) { String given = "The quick brown fox jumped over the moon!"; String given2 = "mary"; String given3 = "D"; //Write a Java code snippet to check (print a boolean) whether the given String ends with the contents of "oon!", see endsWith...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(),...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(), and isEmpty(). For this assignment, enqueue() will be implemented in an unusual manner. That is, in the version of enqueue() we will use, if the element being processed is already in the queue then the element will not be enqueued and the equivalent element already in the queue will be placed at the end of the queue. Additionally, you must implement a circular queue....