CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 1999
    Location
    Arizona
    Posts
    6

    Help with 2 java programs!!

    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


  2. #2
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: Help with 2 java programs!!


    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 ?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured