Solved

exception in thread!

Posted on 2006-06-19
8
271 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
ID: 16933363
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
ID: 16933375
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
ID: 16933378
this is the creditcard class file:

Êþº¾












getBalance
SourceFile
Balance =
CreditCard


0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:basgen
ID: 16933396
seems to have more errors man
0
 
LVL 35

Expert Comment

by:girionis
ID: 16933405
> this is the creditcard class file:

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

Expert Comment

by:Mayank S
ID: 16933544
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
ID: 16935097
>>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:Mayank S
ID: 16941155
? What was the problem and what was the solution?
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 50
couple of eclipse 5 36
Java exception bubble up 2 17
maven module vs maven project 3 21
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

786 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