Browse Source

Works

master
Raphael Roberts 7 years ago
parent
commit
9a5930f87a
  1. 45
      .gitignore
  2. 25
      Account.java
  3. 18
      TestAccount.java

45
.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*

25
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);
}
}

18
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();
}
}
Loading…
Cancel
Save