Skip to content

Commit 60f0ab1

Browse files
committed
Solution
1 parent 956eac7 commit 60f0ab1

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

a.out

2.67 MB
Binary file not shown.

b.out

2.67 MB
Binary file not shown.

bank_account.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,36 @@ class BankAccount {
1111
// Constructor
1212
BankAccount(){
1313
// TODO: Implement the constructor
14+
accountNumber = "000000";
15+
accountHolderName = "Default Account Holder";
16+
balance = 0;
1417
}
1518

1619
BankAccount(const std::string& accNumber, const std::string& accHolder, double initialBalance){
1720
// TODO: Implement the constructor
21+
accountNumber = accNumber;
22+
accountHolderName = accHolder;
23+
balance = initialBalance;
1824
}
1925

2026
// Deposit method
2127
void Deposit(double amount) {
2228
// TODO: Implement the Deposit method
29+
balance += amount;
2330
}
2431

2532
// Withdraw method
2633
void Withdraw(double amount) {
2734
// TODO: Implement the Deposit method
35+
balance -= amount;
2836
}
2937

3038
// Display account information
3139
void DisplayAccountInfo() {
3240
// TODO: Implement the DisplayAccountInfo method
41+
std::cout << "Account Number: " << accountNumber << std::endl;
42+
std::cout << "Account Holder: " << accountHolderName << std::endl;
43+
std::cout << "Balance: " << std::to_string(balance) << std::endl;
3344
}
3445

3546
double GetBalance() const {

factorial.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22

33
// Function to calculate factorial using multiple threads
44
long calculateFactorial(int n) {
5-
long result = 0;
5+
long result = 1;
66
//TODO: Implement the function to calculate factorial of n
7-
7+
if (n < 0) {
8+
throw std::invalid_argument("Invalid argument of " + std::to_string(n) + " less than 0");
9+
}
10+
if (n == 0) {
11+
return 1;
12+
}
13+
for (int i = 1; i <= n; i++) {
14+
result *= i;
15+
}
816
return result;
917
}

0 commit comments

Comments
 (0)