Advertisement
apl-mhd

FirstJavaProgram

May 30th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class AccountInfo {
  4.  
  5.     int accountNo;
  6.     String name;
  7.     float amount;
  8.  
  9.     void insert(int a, String nm, float amnt){
  10.  
  11.         accountNo = a;
  12.         name = nm;
  13.         amount = amnt;
  14.  
  15.     }
  16.  
  17.     void deposit(float amnt){
  18.  
  19.         amount +=amnt;
  20.  
  21.         System.out.println("Diposited amount "+amount);
  22.     }
  23.  
  24.     void withDraw(float amnt){
  25.  
  26.         if(amnt> amount)
  27.             System.out.println("insufficient balance ");
  28.         else{
  29.  
  30.             amount -=amnt;
  31.             System.out.println(amount +"tk " + "withdraw successfully");
  32.         }
  33.  
  34.  
  35.     }
  36.  
  37.  
  38.     void display(){
  39.  
  40.  
  41.         System.out.println("ID: "+accountNo );
  42.         System.out.println("Name: "+name );
  43.         System.out.println("Balance is: " +amount );
  44.     }
  45.  
  46.  
  47.     void checkBalance(){
  48.  
  49.         System.out.println("Balance: " +amount );
  50.  
  51.     }
  52.  
  53.  
  54.     public static void main(String[] args) {
  55.  
  56.         AccountInfo one = new AccountInfo();
  57.  
  58.         one.insert(1,"orko",1000);
  59.  
  60.         one.display();
  61.         one.checkBalance();
  62.         one.deposit(1203);
  63.         one.checkBalance();
  64.         one.withDraw(9);
  65.  
  66.  
  67.     }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement