mirror of
https://github.com/Manoj-HV30/OOPS-lab-codes.git
synced 2026-05-16 19:35:25 +00:00
Added Java lab programs
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,38 @@
|
||||
package accounts;
|
||||
|
||||
public class Account {
|
||||
|
||||
private int accountNumber;
|
||||
private String customerName;
|
||||
private double balance;
|
||||
|
||||
public Account(int accountNumber, String customerName, double balance) {
|
||||
this.accountNumber = accountNumber;
|
||||
this.customerName = customerName;
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public void deposit(double amount) {
|
||||
balance += amount;
|
||||
System.out.println("Amount deposited: " + amount);
|
||||
}
|
||||
|
||||
public void withdraw(double amount) {
|
||||
if (amount <= balance) {
|
||||
balance -= amount;
|
||||
System.out.println("Amount withdrawn: " + amount);
|
||||
} else {
|
||||
System.out.println("Insufficient balance!");
|
||||
}
|
||||
}
|
||||
|
||||
public double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void displayAccountDetails() {
|
||||
System.out.println("Account Number: " + accountNumber);
|
||||
System.out.println("Customer Name: " + customerName);
|
||||
System.out.println("Balance: " + balance);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user