- A PHP command-line tool to convert currencies between AUD, USD, NZD, GBP, and EUR with profit calculation and transaction logging.
This project is created using core PHP, OOP concepts and PSR standards.
- Created custom Router
- Composer
- Namespace
- Dependency Injection
- [1] $ composer install
- [2] $ php -S localhost:8000
- php app app:profit [percentage]
- example:
- [1] $ php app app:profit 15
- [2] $ php app app:profit
Create a currency converter for the following list of currencies:
| Conversion Pair | Rate |
|---|---|
| AUD – USD | 1 USD = 1.5 AUD |
| AUD – NZD | 1 NZD = 0.9 AUD |
| AUD – GBP | 1 GBP = 1.7 AUD |
| AUD – EUR | 1 EUR = 1.5 AUD |
Note:
- The currencies can be converted to and from AUD.
- For example, convert 100 AUD to USD or convert 100 USD to AUD.
PHP command-line script:
-
Accepts three arguments:
- Total amount
- Current currency code (e.g., USD, AUD)
- Currency code to convert to (e.g., USD, AUD)
-
Returns the converted amount on the screen.
-
Saves the conversion record in a simple comma-separated file (
.csv) with the following data:- Initial amount with currency code
- Converted amount with currency code
The company makes a 15% profit on conversions based on the rates above. For example:
- If someone converts 100 USD to AUD (which equals 150 AUD), the company makes 15% of 150 AUD as profit.
- Profit will always be in AUD. So if someone converts 100 AUD to USD, the company earns 15 AUD profit.
Task is to create a command-line script that:
- Reads the CSV file generated in Task 1.
- Calculates and displays the total profit made by the company.
Again, no UI is required.