C# Program to Perform Currency Conversions
Posted by Superadmin on August 13 2022 10:19:04

C# Program to Perform Currency Conversions

 

This is a C# Program to perform currency conversions.

Problem Description

This C# Program Perfoms Currency Conversions.

Problem Solution

Here the currency conversions are made based on the choice that is given by the user and the conversions are made based on the exchange value and the corresponding value is displayed.

Program/Source Code

Here is source code of the C# Program to Perfom Currency Conversions. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Perfom Currency Conversions
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int choice;
            Console.WriteLine("Enter your Choice :\n 1- Dollar to Rupee \n 
                               2- Euro to Rupee \n 3- Malaysian Ringgit to Rupee ");
            choice = int.Parse(Console.ReadLine());
            switch (choice)
            {
            case 1:
                 Double dollar, rupee,val;
                 Console.WriteLine("Enter the Dollar Amount :");
                 dollar = Double.Parse(Console.ReadLine());
                 Console.WriteLine("Enter the Dollar Value :");
                 val = double.Parse(Console.ReadLine());
                 rupee = dollar * val;
                 Console.WriteLine("{0} Dollar Equals {1} Rupees", dollar, rupee);
                 break;
            case 2:
                 Double Euro, rupe,valu;
                 Console.WriteLine("Enter the Euro Amount :");
                 Euro = Double.Parse(Console.ReadLine());
                 Console.WriteLine("Enter the Euro Value :");
                 valu = double.Parse(Console.ReadLine());
                 rupe = Euro * valu;
                 Console.WriteLine("{0} Euro Equals {1} Rupees", Euro, rupe);
                 break;
            case 3:
                 Double ringit, rup,value;
                 Console.WriteLine("Enter the Ringgit Amount :");
                 ringit = Double.Parse(Console.ReadLine());
                 Console.WriteLine("Enter the Ringgit Value :");
                 value = double.Parse(Console.ReadLine());
                 rup = ringit * value;
                 Console.WriteLine("{0} Malaysian Ringgit Equals {1} Rupees", 
                                   ringit, rup);
                 break;
           }
           Console.ReadLine();
        }
    }
}
Program Explanation

This C# program is used to perform currency conversions. Here the currency conversions are made based on the choice that is given by the user and the conversions are made based on the exchange value and the corresponding value is displayed.

 
Runtime Test Cases
 
Enter the Choice :
 1 - Dollar to Rupee
 2 - Euro to Rupee
 3 - Malaysian Ringgit to Rupee
1
Enter the Dollar Amount : 20
Enter the Dollar Value  : 62.58
20 Dollar Equals 1251.6 Rupees