Answer on Question#38078 - 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.
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 CurrencyConverterApplication
{
public partial class Currency_Converter : Form
{
public Currency_Converter()
{
InitializeComponent();
}
private void rateOfExchange_textBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && (e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar.ToString() != ",")
{
e.Handled = true;
MessageBox.Show("Wrong symbol");
}
}
private void amountOfCash_textBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && (e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar.ToString() != ",")
{
e.Handled = true;
MessageBox.Show("Wrong symbol");
}
}
private void Calculate_button_Click(object sender, EventArgs e)
{
double buf = Convert.ToDouble(rateOfExchange_textBox.Text) * Convert.ToDouble(amountOfCash_textBox.Text);
Result_textBox.Text = buf.ToString();
}
}
}