Solved

exception in thread!

Posted on 2006-06-19
8
269 Views
Last Modified: 2010-03-31
i key in this program and it has no errors...however the program cannot run...any reason why it says exception in thread?

public class CreditCard implements CardInterface {
 
  // Instance variables;
  private String number;
  private String name;
  private String bank;
  protected double balance;
  private int limit;
 
  // Constructor
  CreditCard(String no, String nm, String bk, double bal, int lim) {
    number = no;
    name = nm;
    bank = bk;
    balance = bal;
    limit = lim;
  }
 
  // Accessor methods
  public String getNumber()      { return number; }
  public String getName()      { return name; }
  public String getBank()      { return bank; }
  public double getBalance()       { return balance; }
  public int getLimit()       { return limit; }
 
  // Action methods
  public boolean chargeIt(double price) {       // Make a charge
    if (price + balance > (double) limit)
      return false;      // Not enough money left to charge it
    balance += price;
    return true;      // The charge is accepted
  }
  public void makePayment(double payment) {      // Make a payment
    balance -= payment;
  }
  public void print() {                        // Print a card's info
    System.out.println("Number = " + getNumber());
    System.out.println("Name = " + getName());
    System.out.println("Bank = " + getBank());
    System.out.println("Balance = " + getBalance());
    System.out.println("Limit = " + getLimit());
  }
}
   
0
Comment
Question by:basgen
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 35

Expert Comment

by:girionis
Comment Utility
How do you run the programme? I cannot see any main method? You should run a class that has a main method in it.
0
 

Expert Comment

by:Priestex
Comment Utility
The problem doesnt seem to be in this class.
Its probably becuause of the code that you are calling this class from.

Can you post that.
And also the definition of the interface you are implementing in this class.
0
 

Author Comment

by:basgen
Comment Utility
this is the creditcard class file:

Êþº¾












getBalance
SourceFile
Balance =
CreditCard


0
 

Author Comment

by:basgen
Comment Utility
seems to have more errors man
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 35

Expert Comment

by:girionis
Comment Utility
> this is the creditcard class file:

I can't see anything, what encoding are you using?
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
Same here. There must be another class that has a main () method - search for that one and run it.

Searching will be easier if you have some IDE like Eclipse, so download it - www.eclipse.org
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
Comment Utility
>>this is the creditcard class file:

You're trying to post the binary. You should be posting the source code *of the class calling the CreditCard class*
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
? What was the problem and what was the solution?
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now