Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f021d22

Browse files
Create Account.java
1 parent c7dd8a0 commit f021d22

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

‎Account.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import java.util.Scanner;
2+
class Account{
3+
int accountNumber;
4+
String accountHolderName;
5+
double balance;
6+
7+
Account(int acc_no,string ac_holder,double bal)
8+
{
9+
accountNumber=acc_no;
10+
accountHolderName=ac_holder;
11+
balance=bal;
12+
}
13+
14+
public void deposit(double amount)
15+
{
16+
if(amount>0)
17+
{
18+
balance += amount;
19+
}
20+
else
21+
{
22+
System.out.println("Invalid Amount");
23+
}
24+
}
25+
26+
public void withdraw(double amount)
27+
{
28+
if(amount>0 && amount<=balance)
29+
{
30+
balance -= amount;
31+
}
32+
else
33+
{
34+
System.out.println("Amount can't be withdrawn");
35+
}
36+
}
37+
public void displayAccountInfo()
38+
{
39+
System.out.println("Account Number:"+accountNumber);
40+
System.out.println("Account Number:"+accountHoldername);
41+
System.out.println("Balance:"+balance);
42+
}
43+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /