C# program for Currency Conversion

C# Program to Convert the Rupees Amount To other Currency Amount

Today, I have shared a C# program that converts the rupees amount into equivalent Dollar, Franc and Euro amount. The amount of Dollar, Franc & Euro are changed daily. So as per your requirement you can change the amount to get the accurate result.

Note:  Here I had used a goto statement to make a program in repeated mode as the user doesn't input the value for exit i.e. 4 in my case.


Lets review the code...

/* C# Program for Currency Conversion*/

using System;

namespace PracticalSet1_6
{
    class CurrencyConverter
    {
        static void Main(string[] args)
        {
            int ch = 0;
            double rupees;
            Console.WriteLine("Program for the currency converter...");
            Converter:   //Label for making program in continuous mode.
            while(ch!=4)
            {
                Console.WriteLine("1. Rupees to Dollar.");
                Console.WriteLine("2. Rupees to Frank.");
                Console.WriteLine("3. Rupees to Euro.");
                Console.WriteLine("4. Exit. ");
                Console.Write("Enter your choice:");
                ch = Convert.ToInt32(Console.ReadLine());
                switch (ch)
                {
                    case 1:  //Convert Rupees to Dollar...
                    {
                        Console.Write("Enter your amount in rupees:");
                        rupees = Convert.ToDouble(Console.ReadLine());
                        Console.WriteLine("Currency amount in dollar:" + (rupees / 65));
                        break;
                    }

                    case 2: //Convert Rupees To Franc...
                    {
                        Console.Write("Enter your amount in rupees:");
                        rupees = Convert.ToDouble(Console.ReadLine());
                        Console.WriteLine("Currency amount in franc:" + (rupees / 70));
                        break;
                    }

                    case 3: //Convert Rupees to Euro...
                        {
                        Console.Write("Enter your amount in rupees:");
                        rupees = Convert.ToDouble(Console.ReadLine());
                        Console.WriteLine("Currency amount in euro:" + (rupees / 80));
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Enter the valid choice...");
                        goto Converter;   //goto statement for looping of program...
                    }
                }
            }
        }
    }
}

Output:

Program for the currency converter...
1. Rupees to Dollar.
2. Rupees to Frank.
3. Rupees to Euro.
4. Exit.
Enter your choice:1
Enter your amount in rupees:65
Currency amount in dollar:1

1. Rupees to Dollar.
2. Rupees to Frank.
3. Rupees to Euro.
4. Exit.
Enter your choice:2
Enter your amount in rupees:70
Currency amount in franc:1

1. Rupees to Dollar.
2. Rupees to Frank.
3. Rupees to Euro.
4. Exit.
Enter your choice:3
Enter your amount in rupees:80
Currency amount in euro:1

1. Rupees to Dollar.
2. Rupees to Frank.
3. Rupees to Euro.
4. Exit.
Enter your choice:4    //It exit from the program


Happy Coding:)

Comments

Popular posts from this blog

MultiSelection of Item in Recycler View

Upload Image From Android To Php Server

Merge Sort