Guest User

Untitled

a guest
May 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package javaapplication1;
  6. import javax.swing.JOptionPane;
  7. /**
  8.  *
  9.  * @author Cody
  10.  */
  11. public class JavaApplication1 {
  12.  
  13.     public class BankAccount{
  14.         float balance;
  15.         float interestRate;
  16.         //String compondPeriod;
  17.         public BankAccount() {
  18.             this.balance = 0.00;
  19.             this.interestRate = 0.00;
  20.             //this.compondPeriod="";
  21.         }
  22.        
  23.         public void setBalance(float amount){
  24.             this.balance = amount;          
  25.         }
  26.         public void setInterestRate(float rate){
  27.             this.interestRate = rate;
  28.         }
  29.        
  30.         public void showBalance(){
  31.             JOptionPane.showMessageDialog(null, this.balance);
  32.         }
  33.        
  34.         public void showInterestRate(){
  35.             JOptionPane.showMessageDialog(null, this.interestRate);
  36.         }
  37.         /*
  38.          public float calculateBalance(int compoundPeriod){
  39.             for(int i = compoundPeriod;i>0;i--){
  40.                 this.balance *= 1+interestRate;
  41.             }
  42.            
  43.         }
  44.        */
  45.     }
  46.    
  47.     public static void main(String[] args){
  48.         BankAccount account1;
  49.         String balance = JOptionPane.showInputDialog(null, "Please enter the amount in your account");
  50.         String interestRate = JOptionPane.showInputDialog(null, "Please the interest rate in %");
  51.        
  52.         float balance2 = Float.parseFloat(balance);
  53.         float rate = Float.parseFloat(interestRate);
  54.         rate /=100;
  55.         account1.setBalance(balance2);
  56.         account1.setInterestRate(rate);
  57.        
  58.        
  59.         account1.showBalance();
  60.         account1.showInterestRate();
  61.        
  62.         sayHelloTo(balance);
  63.         // TODO code application logic here
  64.     }
  65.    
  66.     public static void sayHelloTo(String nameToGreet){
  67.         JOptionPane.showMessageDialog(null, "Hello, " + nameToGreet + "!");
  68.     }
  69.    
  70.    
  71.    
  72. }
Add Comment
Please, Sign In to add comment