Tugas 2 PBKK A : Aplikasi Sederhana

ditugaskan untuk membuat aplikasi desktop sederhana. disini saya membuat kalkulator kurs mata uang sederhana . Berikut aplikasi yang saya buat menggunakan .NET



Source code 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

namespace MyFirstWinFormsApp

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {

            convertCurrency();

        }

 

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)

        {

            convertCurrency();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            convertCurrency();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            this.comboBox1.SelectedItem = "IDR";

            this.comboBox2.SelectedItem = "IDR";

            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

            this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;

        }

 

        private void label1_Click(object sender, EventArgs e)

        {

 

        }

 

        private void label2_Click(object sender, EventArgs e)

        {

            convertCurrency();

        }

 

        private void label3_Click(object sender, EventArgs e)

        {

 

        }

 

        private void convertCurrency()

        {

            double inputNum = (double)(this.numericUpDown1.Value);

            string in_currency = this.comboBox1.SelectedItem.ToString();

            string out_currency = this.comboBox2.SelectedItem.ToString();

 

            double pembagi = 0.0;

            if (out_currency == "USD") divider = 0.000069;

            else if (out_currency == "IDR") divider = 1;

            else if (out_currency == "SGD") divider = 0.000093;

            else if (out_currency == "GBP") divider = 0.000050;

            else if (out_currency == "EUR") divider = 5.8 / 10000000;

 

            double pengali = 0.0;

 

            if (in_currency == "USD") pengali = 14391.45;

            else if (in_currency == "IDR") multiplier = 1;

            else if (in_currency == "SGD") multiplier = 10743.06;

            else if (in_currency == "GBP") multiplier = 19949.14;

            else if (in_currency == "EUR") multiplier = 17176.45;

 

            double outnum = inputNum * pengali / pembagi;

 

            this.label2.Text = out_currency + " " + Math.Round(outnum, 6);

        }

    }

}

 


Comments

Popular posts from this blog

Tugas 1 PWEB D : CV

Tugas 8 RK B : BOM dan Feature Tree

Tugas 8 PWEB D : PHP