63 814
Assignments Done
99,5%
Successfully Done
In August 2018

Answer to Question #40761 in C# for devendra khairwa

Question #40761
Michael is a software developer in FIT technologies. He wants to add a currency converter in the
application for the convenience of international customers. Help Michael in creating the currency
converter in c#.
Expert's answer
Answer on Question#40761- Programming, C#

1. Michael is a software developer in FIT technologies. He wants to add a currency converter in the
application for the convenience of international customers. Help Michael in creating the currency
converter in c#.

Solution.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Translate_button1_Click(object sender, EventArgs e)
{
double usd;
double k;
double rub;
try
{
usd = Convert.ToDouble(Currency_textBox1.Text);
k = Convert.ToDouble(Amount_textBox2.Text);

rub = usd * k;
Result_textBox3.Text = rub.ToString("C");
}
catch { }
}

private void Currency_textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= '0') && (e.KeyChar <= '9'))
return;
if (e.KeyChar == '.')
e.KeyChar = ',';
if (e.KeyChar == ',')
{
if ((Currency_textBox1.Text.IndexOf(',') != -1) ||
(Currency_textBox1.Text.Length == 0))
{
e.Handled = true;
}
return;
}
if (Char.IsControl(e.KeyChar))
{
if (e.KeyChar == (char)Keys.Enter)
{
if (sender.Equals(Currency_textBox1))
Amount_textBox2.Focus();
else
Translate_button1.Focus();
}
return;
}
e.Handled = true;
}

private void Currency_textBox1_TextChanged(object sender, EventArgs e)
{
Result_textBox3.Text = "";
}


}
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions