Sharp Tutorial
bank class with deposit and withdraw methods

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

Week 1

  • Ans of Question 1
  • Ans of Question 2
  • Ans of Question 3
  • Ans of Question 4
  • Ans of Question 5

Week 2

  • Ans of Question 1
  • Ans of Question 2
  • Ans of Question 3
  • Ans of Question 4
  • Ans of Question 5

Week 3

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5

Week 4

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5

Week 5

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5

Solution of java assignment questions

Bank Class with deposit and Withdraw Methods

class Bank
{
	int accNo;
	String name=null;
	int balance;
	
	void setData(int a, String n, int b)
	{
		accNo=a;
		name=n;
		balance=b;
	}

    void deposit(int amt)
	{
		balance=balance+amt;
	}
    
	void withdraw(int amt)
	{
		if(amt<=balance)
		balance=balance-amt;
	    else
		 System.out.println("not sufficient Fund");	
	
	}
	
	void display()
	{
		System.out.println("Acc No="+accNo+" Name: "+name+" balance="+balance);
		
	}
	
}

class checkMain
{
public static void main(String args[])
{

Bank b1= new Bank();
b1.setData(10001,"john",5000);
b1.deposit(1000);
b1.withdraw(2000);
b1.display();
}

}	
Watch video in full size

Video tutorial

Click To Read: SQL Tutorial With Easy Example Queries.

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial