-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
52 lines (39 loc) · 1.21 KB
/
Main.java
File metadata and controls
52 lines (39 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// BankAccount class represents a simple bank account
class BankAccount {
// Private variable to store account number
private int accountNumber;
// Private variable to store account balance
private double balance;
// Method to set the account number
public void setAccountNumber(int num) {
accountNumber = num;
}
// Method to set the account balance
public void setBalance(double bal) {
balance = bal;
}
// Method to get the account number
public int getAccountNumber() {
return accountNumber;
}
// Method to get the account balance
public double getBalance() {
return balance;
}
}
// Main class
public class Main {
// Main method - program execution starts here
public static void main(String[] args) {
// Create an object of BankAccount
BankAccount acc = new BankAccount();
// Set account number
acc.setAccountNumber(12345);
// Set account balance
acc.setBalance(5000);
// Print account number
System.out.println("Account Number: " + acc.getAccountNumber());
// Print account balance
System.out.println("Balance: " + acc.getBalance());
}
}