Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💱 Currency Converter & Profit Calculator CLI Tool

  • A PHP command-line tool to convert currencies between AUD, USD, NZD, GBP, and EUR with profit calculation and transaction logging.

About This Project

This project is created using core PHP, OOP concepts and PSR standards.

  • Created custom Router
  • Composer
  • Namespace
  • Dependency Injection

To run the Project

  • [1] $ composer install
  • [2] $ php -S localhost:8000

To get total profit using command

  • php app app:profit [percentage]
  • example:
  • [1] $ php app app:profit 15
  • [2] $ php app app:profit

Task 1: Currency Converter

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:

    1. Total amount
    2. Current currency code (e.g., USD, AUD)
    3. 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:

    1. Initial amount with currency code
    2. Converted amount with currency code

Task 2: Profit Calculation (Continuation of Task 1)

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.


About

A PHP command-line tool to convert currencies between AUD, USD, NZD, GBP, and EUR, with profit calculation and transaction logging.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages