Guest User

Untitled

a guest
May 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 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.        
  18.        
  19.         public void setBalance(float amount){
  20.             this.balance = amount;          
  21.         }
  22.         public void setInterestRate(float rate){
  23.             this.interestRate = rate;
  24.         }
  25.        
  26.         public void showBalance(){
  27.             JOptionPane.showMessageDialog(null, this.balance);
  28.         }
  29.        
  30.         public void showInterestRate(){
  31.             JOptionPane.showMessageDialog(null, this.interestRate);
  32.         }
  33.        
  34.         public BankAccount() {
  35.             this.balance = 0;
  36.             this.interestRate = 0.00;
  37.             //this.compondPeriod="";
  38.         }
  39.         /*
  40.          public float calculateBalance(int compoundPeriod){
  41.             for(int i = compoundPeriod;i>0;i--){
  42.                 this.balance *= 1+interestRate;
  43.             }
  44.            
  45.         }
  46.        */
  47.     }
  48.    
  49.     public static void main(String[] args){
  50.         BankAccount account1;
  51.         String balance = JOptionPane.showInputDialog(null, "Please enter the amount in your account");
  52.         String interestRate = JOptionPane.showInputDialog(null, "Please the interest rate in %");
  53.        
  54.         float balance2 = Float.parseFloat(balance);
  55.         float rate = Float.parseFloat(interestRate);
  56.         rate /=100;
  57.         account1.setBalance(balance2);
  58.         account1.setInterestRate(rate);
  59.        
  60.        
  61.         account1.showBalance();
  62.         account1.showInterestRate();
  63.        
  64.         sayHelloTo(balance);
  65.         System.exit(0);
  66.         // TODO code application logic here
  67.     }
  68.    
  69.     public static void sayHelloTo(String nameToGreet){
  70.         JOptionPane.showMessageDialog(null, "Hello, " + nameToGreet + "!");
  71.     }
  72.    
  73.    
  74.    
  75. }
Add Comment
Please, Sign In to add comment