Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# Programming: Write a GUI program named CurrencyConverterGUI that allows a use

ID: 669589 • Letter: C

Question

C# Programming:

Write a GUI program named CurrencyConverterGUI that allows a user to enter a dollar amount in the first text box that should be converted to the selected currency and displayed in the second text box whenever a currency command button is clicked.

The label preceding the second text box should also change to reflect the name of the selected currency. You can use flags preceding the labels to identify the country. Hint: Each command click event will have at least three code statements. One will display the converted amount, one will display the flag and one will change the caption property of the label control.

Use the following exchange rates. One dollar equals:

.64 Pounds

75.5 Marks

99.53 Yen

1.05 Canadian Dollar

(If you ask for a conversion when the dollar box is empty, you should get a run-time error.)

Explanation / Answer

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1(){
            InitializeComponent();
        }
      
        double convert(int i,int a ){
           if (a == 1) return i*0.64;
           else if (a == 1) return i*75.5;
           else if (a == 1) return i*99.53;
           return i*1.05;
        }

        private void Form1_Load(object sender, EventArgs e){
            textBox1.Width = 250;
            textBox1.Height = 50;
            textBox1.Multiline = true;
            textBox1.BackColor = Color.Blue;
            textBox1.ForeColor = Color.White;
            textBox1.BorderStyle = BorderStyle.Fixed3D;
          
            textBox2.Width = 250;
            textBox2.Height = 50;
            textBox2.Multiline = true;
            textBox2.BackColor = Color.Blue;
            textBox2.ForeColor = Color.White;
            textBox2.BorderStyle = BorderStyle.Fixed3D;
      
           label1.Text = "Pounds";
              label1.BorderStyle = BorderStyle.FixedSingle;  
            label1.TextAlign = ContentAlignment.MiddleCenter;
        }

        private void button1_Click(object sender, EventArgs e){
            string var = textBox1.Text;
            if (var != ""){
                  int i = Int32.Parse(var);
                  TextBox2.setText(convert(i,1)+"");
            }
        }
    }
}