Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Cody
- */
- public class JavaApplication1 {
- public class BankAccount{
- float balance;
- float interestRate;
- //String compondPeriod;
- public void setBalance(float amount){
- this.balance = amount;
- }
- public void setInterestRate(float rate){
- this.interestRate = rate;
- }
- public void showBalance(){
- JOptionPane.showMessageDialog(null, this.balance);
- }
- public void showInterestRate(){
- JOptionPane.showMessageDialog(null, this.interestRate);
- }
- public BankAccount() {
- this.balance = 0;
- this.interestRate = 0.00;
- //this.compondPeriod="";
- }
- /*
- public float calculateBalance(int compoundPeriod){
- for(int i = compoundPeriod;i>0;i--){
- this.balance *= 1+interestRate;
- }
- }
- */
- }
- public static void main(String[] args){
- BankAccount account1;
- String balance = JOptionPane.showInputDialog(null, "Please enter the amount in your account");
- String interestRate = JOptionPane.showInputDialog(null, "Please the interest rate in %");
- float balance2 = Float.parseFloat(balance);
- float rate = Float.parseFloat(interestRate);
- rate /=100;
- account1.setBalance(balance2);
- account1.setInterestRate(rate);
- account1.showBalance();
- account1.showInterestRate();
- sayHelloTo(balance);
- System.exit(0);
- // TODO code application logic here
- }
- public static void sayHelloTo(String nameToGreet){
- JOptionPane.showMessageDialog(null, "Hello, " + nameToGreet + "!");
- }
- }
Add Comment
Please, Sign In to add comment