ch6,ch7,ch8,ch9,ch10,ch11,ch12 _ sol manual

ch6,ch7,ch8,ch9,ch10,ch11,ch12 _ sol manual - /* /...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************* // Account.java // // A bank account class with methods to deposit, withdraw, // and check the balance. //******************************************************* public class Account { private double balance; private String name; private long acctNum; private static int numAccounts; //---------------------------------------------- //Constructor -- initializes balance and owner; generates random //account number //---------------------------------------------- public Account(double initBal, String owner) { balance = initBal; name = owner; acctNum = (int) (Math.random() * Integer.MAX_VALUE); numAccounts++; } //---------------------------------------------- // Checks to see if balance is sufficient for withdrawal. // If so, decrements balance by amount; if not, prints message. //---------------------------------------------- public void withdraw(double amount) { if (balance >= amount) balance -= amount; else System.out.println("Insufficient funds");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Page1 / 3

ch6,ch7,ch8,ch9,ch10,ch11,ch12 _ sol manual - /* /...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online