diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ddcce44 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# C:ompiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid*# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/Account.java b/Account.java new file mode 100644 index 0000000..f047636 --- /dev/null +++ b/Account.java @@ -0,0 +1,25 @@ +public class Account{ + int id = 0; + double startBalance = 0; + double endBalance = 0; + double monthlyInterestRate = 0.03; + double interest; + public Account (){ + } + public Account (int id, double balance, double monthlyInterestRate){ + this.id = id; + this.startBalance = balance; + this.monthlyInterestRate = monthlyInterestRate; + } + public void computeInterest(){ + this.interest = this.startBalance * this.monthlyInterestRate; + this.endBalance = this.startBalance+this.interest; + } + public void printAccountInfo(){ + // this.computeInterest(); + System.out.println("Account ID: " + this.id); + System.out.println("Account Balance: " + this.startBalance); + System.out.println("Interest gained: " + this.interest); + System.out.println("New balance: " + this.endBalance); + } +} \ No newline at end of file diff --git a/TestAccount.java b/TestAccount.java new file mode 100644 index 0000000..1b264d8 --- /dev/null +++ b/TestAccount.java @@ -0,0 +1,18 @@ +public class TestAccount{ + public static void main(String[] args){ + Account ac1 = new Account(100,500.00,0.03); + Account ac2 = new Account(200,1250.00,0.03); + Account ac3 = new Account(300,700.00,0.02); + ac1.computeInterest(); + ac1.printAccountInfo(); + System.out.println(); + + ac2.computeInterest(); + ac2.printAccountInfo(); + System.out.println(); + + ac3.computeInterest(); + ac3.printAccountInfo(); + System.out.println(); + } +} \ No newline at end of file