Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

cannot implicitly convert type string to double

$
0
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Currency
{
    class Program
    {
        static void Main(string[] args)
        {
            // Declare Source and Target Currency.
            string SCurrency, TCurrency;

            //Declare and intialising a String currency array and a Double rate array.
            String[] currency = new String[] {"Euro","Rupees","Dirhams"};
            double[] rateAR =new double[] {0.73,62.68,3.67};
            double TAmount,SAmount,Rate;

            //Printing the TITLE and setting font color.
            Console.Title = "Currency Application";
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("********CURRENCY CONVERTOR*********");

            //Getting the Source and Target Currency.
            Console.WriteLine("Enter the source currency in Dollars: ");
            SCurrency = System.Console.ReadLine();
            Console.WriteLine("Enter the target currency : ");
            TCurrency = System.Console.ReadLine();
            Console.WriteLine("Enter the amount to convert : ");
            SAmount = System.Console.ReadLine(); ------------ > ERROR
            for(int i=0;i<3;i++)
            {
                if (TCurrency == currency[i])
                {
                    rateAR[i]=Rate;
                }
            }

            TAmount = SAmount * Rate;
            String StringAmount = Convert.ToString(TAmount);
            System.Console.WriteLine("Converted Amount : " + StringAmount + ".");

            Console.BackgroundColor = ConsoleColor.Black;


            Console.ReadLine();

Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>