Solved

exception in thread!

Posted on 2006-06-19
8
274 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaFX TableView not displaying correctly 3 146
java imports not found 4 67
Eclipse Java import and method not resolved 4 123
junit example issue 2 51
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

739 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