compsci ch3 - /* *SavingsAccount.java *exercise3.3...

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

View Full Document Right Arrow Icon
/* * SavingsAccount.java * exercise 3.3 * @author darsh */ public class SavingsAccount { double balance, interest; /** Creates a new Savings Account with an initial balance, and an interest rate. * */ public SavingsAccount(double initBalance, double initInterest) { balance = initBalance; interest = initInterest; } /** * Adds interest to the balance * @param addinterest Adds interest to the current balance */ public void addInterest() { balance = balance + (balance * interest); } }
Background image of page 1

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

View Full DocumentRight Arrow Icon
/** *@author darsh *exercise 3.3 *Savings Account Program */ /** * A bank account that calculates savings and interest/ */ public class SavingsTester { public static void main(String args[]) { SavingsAccount savings = new SavingsAccount(1000,0.1); savings.addInterest(); savings.addInterest(); savings.addInterest(); savings.addInterest(); savings.addInterest(); System.out.println("The balance in the account is: $" + savings.balance); } }
Background image of page 2
/** * @author darsh * creates a circle with a given radius */ public class Circle {
Background image of page 3

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

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

This note was uploaded on 02/22/2009 for the course ECE 495K taught by Professor Vijaykumar during the Spring '08 term at Purdue University-West Lafayette.

Page1 / 9

compsci ch3 - /* *SavingsAccount.java *exercise3.3...

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

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