Drop links or images here to add them to the editor.

A simple currency conversion utility.

★★☆

Currency and exchange were important elements of trade in the ancient world, enabling people to buy and sell items like food, pottery, and raw materials. If a Greek coin held more gold than an Egyptian coin due to its size or content, then a merchant could barter fewer Greek gold coins for more Egyptian ones, or for more material goods. This is why, at some point in their history, most world currencies in circulation today had a value fixed to a specific quantity of a recognised standard like silver and gold.

Currency converter

Make

Write a program that converts Great British Pounds (GBP) into United States Dollar (USD), Euro, Yuan or Yen.

Success Criteria

Remember to add a comment before a subprogram or selection statement to explain its purpose.

Complete the subprogram called exchange so that:

  1. It returns the amount of money in the chosen currency:
  2. 1 Great British Pounds (GBP) = 1.3 USD (United States Dollars).
  3. 1 Great British Pounds (GBP) = 1.11 Euro.
  4. 1 Great British Pounds (GBP) = 8.92 Yuan.
  5. 1 Great British Pounds (GBP) = 138.44 Yen.

Complete the main program so that:

  1. The user can input the number of Great British Pounds.
  2. The user can enter the chosen currency from USD, Euro, Yuan or Yen.
  3. It outputs the amount of money in the chosen currency.

Typical inputs and outputs from the program would be:

Enter the number of Great British Pounds:
200
Enter the currency (USD, Euro, Yuan, Yen):
USD
200.0 GBP = 260.0 USD
Enter the number of Great British Pounds:
205
Enter the currency (USD, Euro, Yuan, Yen):
Euro
205.0 GBP = 227.55 Euro
🆘 If you're really stuck, use this Parsons code sorting exercise
Complete program
// Currency converter program

using System;

class Submission
{
---
    // -------------------------
    // Subprograms
    // -------------------------
    // Return money using exchange rate
---
    static double exchange(double gbp, string currency)
    {
---
        double money = 0;
        // US Dollars
        if (currency == "USD")
        {
---
            money = gbp * 1.3;
---
        }
---
        // European Euros
        else if (currency == "Euro")
        {
---
            money = gbp * 1.11;
---
        }
---
        // Chinese Yuan
        else if (currency == "Yuan")
        {
---
            money = gbp * 8.92;
---
        }
---
        // Japanese Yen
        else if (currency == "Yen")
        {
---
            money = gbp * 138.44;
---
        }
---
        return money;
---
    }
---

    // -------------------------
    // Main program
    // -------------------------
    public static void Main(string[] args)
    {
---
        Console.WriteLine("Enter the number of Great British Pounds:");
        double gbp = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Enter the currency (USD, Euro, Yuan, Yen):");
        string currency = Console.ReadLine();
---
        double money = exchange(gbp, currency);
---
        Console.WriteLine($"{gbp} GBP = {money} {currency}");
---
    }
---
}