Solved

exception in thread!

Posted on 2006-06-19
8
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

724 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