Click to See Complete Forum and Search --> : Help with 2 java programs!!


Tannas
October 3rd, 1999, 09:58 PM
I am enroled in a class called "Principle Programming" and am having some trouble with the class. We deal mostly with java and I can't seem to understand it whatever I do. There are 2 programs I'm having trouble with, they are listed below:

javacode

// CheckingAccount.java
// no main method, as all methods are called

import java.io.*;
public class CheckingAccount {
// Data fields
private double balance;

public void readBalance() throws IOException

{
BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in));
System.out.println("Enter your current balance.");

balance = Double.parseDouble(stdin.readLine());
} // method readBalance


public void payAllBills() throws IOException
{
while (balance > 0)
{
Bill bills = new Bill();
double payment = bills.readBill();

if (balance >=0) {
balance = balance - payment;
System.out.print("Your new balance is the paltry sum of $");
displayBalance();
System.out.println();
}

else
System.out.println("Get a job, you worthless scumbag. You're broke!");
}

public double displayBalance()
{
System.out.print(balance);
}






}
/javacode

javacode

// Filename: BillPayer.java
import java.io.*;
public class BillPayer
{
public static void main (String[]args) throws IOException
{
CheckingAccount myaccount = new CheckingAccount();
myaccount.readBalance();
}
}

/javacode

poochi
October 4th, 1999, 12:49 AM
What trouble you are having with these two classes ?

There is one main class(BillPayer) and one business class ( Checking Account ). In Java ,
in general , business classes wont have the main function. Here , you are creating an
instance of a Business Object in your main class.

Can you please tell us what problem you are having ?