To Exercises

.Net Developer Program
Currency Exercise
Exercise 1

Goal: Practice creating a console based application that uses arrays and the Console.WriteLine procedure.

Here is a sample output for your application.

Enter the source currency:
Dollars
Enter the target currency:
Euro
Enter the amount:
1000
1000 Dollars give you 772.80 Euro.
Would you like to convert another amount?

  1. Create a console based C# solution called Currency.

  2. Declare and initialize a String array named currency with the values "Pounds", "Dollars", "Euro", "Rupee", and "Ruble".

  3. Declare and initialize a double array named rate with the values 0.508278, 1.0000, 0.637323, 39.9800, 23.5805.

  4. Issue prompts with System.Console.WriteLine and read input with System.Console.ReadLine as shown in the sample output.

  5. Use a for loop to find the array index of the array currency called sourceIndex corresponding to the source currency. Do the same thing to find the targetIndex corresponding to the target currency.

  6. Use the formula to convert from the source currency to the target currency:

    targetAmount = sourceAmount / rate[sourceIndex]
         * rate[targetIndex];

  7. Print the result using System.Console.WriteLine as shown in the sample output. Use the ToString method of double to format the result.

  8. Add a while loop to keep asking if the user wishes to do another conversion.