0% found this document useful (0 votes)
6 views2 pages

Java Account Class for Deposits & Withdrawals

Java Practical 03

Uploaded by

Riya Jayswal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Java Account Class for Deposits & Withdrawals

Java Practical 03

Uploaded by

Riya Jayswal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Input:-

Java Practical 03:-

// Creating an account class within mass deposit() and

// creating a test class to deposit and withdraw amount

public class Account{

int acc_no;

String name;

float amount;

// Method to intalize object

void insert(int a, String n, float amt){

acc_no = a ;

name = n;

amount = amt; }

// Despoit method

void deposit(float amt){

amount = amount+amt;

[Link](amt+" Deposited"); }

// withdraw method

void withdraw (float amt){

if(amount< amt){

[Link]("Insufficient balance"); }

else{

amount = amount-amt;

[Link](amt+" withdrawn"); } }

void checkBalance(){

[Link]("Balance is: "+amount); }

// method to display the values of an object


void display(){

[Link](acc_no+" "+name+" "+amount); }

public static void main(String[] args){

Account a1 = new Account();

[Link](12345,"Aditi",4000);

[Link]();

[Link]();

[Link](45000);

[Link]();

[Link](25000);

[Link](); } }

• Output:-

12345 Aditi 4000.0

Balance is: 4000.0

45000.0 Deposited

Balance is: 49000.0

25000.0 withdrawn

Balance is: 24000.0

You might also like