qu
answer
Homepage
Ask!
Experts
Search
English
Notifications
Login
qu
answer
Homepage
Experts
Ask!
Notifications
Login
Loading...
>
#programming
,
#java
>
Write a java program to create a class known as "Bank Account"with methods called deposit() and withdrawal (). ?
Anonymous
more than 4 weeks ago
Subscribe
Subscribed
Copy Link
Share
Embed
Report Question
#programming
#java
Write a java program to create a class known as "Bank Account"with methods called deposit() and withdrawal (). ?
Share
1 view
Share
1 view
1
answer
Sort By
Date
Score
ChatGPT
more than 4 weeks ago
Report Answer
public class BankAccount {
private double balance;
public BankAccount(double initialBalance) {
balance = initialBalance;
}
public void deposit(double amount) {
balance += amount;
System.out.println(amount + " deposited successfully.");
}
public void withdrawal(double amount) {
if (balance >= amount) {
balance -= amount;
System.out.println(amount + " withdrawn successfully.");
} else {
System.out.println("Insufficient funds.");
}
}
public double getBalance() {
return balance;
}
public static void main(String[] args) {
BankAccount account = new BankAccount(1000);
System.out.println("Initial balance: " + account.getBalance());
account.deposit(500);
System.out.println("Current balance after deposit: " + account.getBalance());
account.withdrawal(200);
System.out.println("Current balance after withdrawal: " + account.getBalance());
account.withdrawal(1500);
}
}
0
Te
Click here to log in
uploading image...
Anonymous answer
Add Answer
Similar Questions
Weka shadda kwenye maneno yafuatayo a)Darasa b)Walakini(dosari)???
What are foreign keys?
What are primary keys?
Assume you are a chain surveyor expert in one of the village and you have been assigned task of measuring adistance of ariver from point ato b.which seven steps you follow to carry out such a task ?
With evidence from the map of sikonge, describe the nature of relief in the mapped area?
Calculate the gradient from grid difference 835846 to 782786of map of sikonge?
The form three students were told by their geography teacher to perform a survey activity around the school compound.explain 8 pre survey activities they need to consider ?
Migration is caused by both pull and push factor.using 6 points justify statements ?
In 6 points explain lessons that Tanzania tourism industry has to learn from Switzerland so as to improve more in this sector ?
Mention other 6possible source of research problems for the similar study?
×
Please log in to continue.
×
Login with Facebook
Login with Google
Login with Twitter
By proceeding, you agree to our
Terms Of Use
and confirm you have read our
Privacy Policy
.
OR
Click here to log in
Embed
×
Width
px
Height
px
Dynamic width
Show picture
Show description
Title - visible rows
1
2
3
4
5
6
7
8
9
10
Description - visible rows
1
2
3
4
5
6
7
8
9
10
×
Sexual content
Violent or repulsive content
Hateful or abusive content
Spam or misleading
Infringes my rights
Other
Request to block the user (the user will not have permission to post on Quanswer).
Please select a reason before submitting the report.
Thank you for helping us keep the content on Quanswer as high-quality as possible. We received your feedback and we will review it shortly.
×
Anonymous
Login
Ask!
Homepage
Experts
Tags
Search
Be one of the experts
About Us
Frequently Asked Questions
Contact Us
Terms Of Use
Privacy Policy
© 2024 - Quanswer
Select language
×
Magyar
Română
Español
Kiswahili
Français
Português