Modify the factorial.hpp file for computing the factorial of a given number.
This task will introduce you to basic control structures (loops) and basic mathematical operations in C++.
Hint: the factorial for negative numbers is not defined, so you will need to raise an ìnvalid_argument`exception in that case. Go look online how to do that 😉
Test Case:
Input: 5
Output: 120
Mathematically, the factorial of a number n is n!, which is given by either
1. n! = 1 x 2 x 3 x … x (n-2) x (n-1) x n
2. n! = n x (n-1)!
Modify the file bank_account.hpp that defines a simple bank account class. The class should have the following properties and methods:
- Properties:
- Account Number
- Account Holder Name
- Balance
- Methods:
- Constructor: Initialize the account with an account number, account holder name, and initial balance.
- Deposit: Accept an amount and add it to the balance.
- Withdraw: Accept an amount and deduct it from the balance. Make sure the withdrawal doesn't exceed the available balance.
- Display Account Information: Display the account number, account holder name, and balance.
The program will prompt the user to enter the bank account number, account name, and initial balance, and then create an instance of the BankAccount class using the provided input. It will then demonstrate the usage of the class by performing deposits and withdrawals and displaying account information.
Test Case:
Input: > bank_account.exe
Output: