PBKK A - Tugas 2


Assalamualaikum Warrahmatullahi Wabarakatuh , saya Rihan Farih Bunyamin. Saya merupakan mahasiswa Institut Teknologi Sepuluh Nopember Surabaya jurusan Teknik Informatika angkatan 2019 dengan NRP 05111940000165.

Pada pertemuan kedua di PBKK ini kami ditugaskan untuk membuat aplikasi desktop sederhana. disini kami membuat kalkulator kurs mata uang sederhanna . adapun tahap-tahap cara membuatnya seperti dibawah ini" 

Pilih Create a new project

Pilih Windows Forms App, lalu klik next

Masukkan nama project dan lokasi penyimpanan, kemudian klik Next
Pilih framework .NET Core 3.1 (Long-term support) lalu klik Create









 Setelah itu akan muncul tampilan form kosong, lalu buatlah form tersebut menyerupai gambar diatas. Caranya adalah drag n drop dari toolbox dan ganti namanya di properties. Jika sudah, klik kanan formnya lalu view code, lalu isikan code seperti dibawah ini : 

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 senderEventArgs e)
        {
            convertCurrency();
        }
 
        private void numericUpDown1_ValueChanged(object senderEventArgs e)
        {
            convertCurrency();
        }
 
        private void button1_Click(object senderEventArgs e)
        {
            convertCurrency();
        }
 
        private void Form1_Load(object senderEventArgs e)
        {
            this.comboBox1.SelectedItem = "IDR";
            this.comboBox2.SelectedItem = "IDR";
            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
        }
 
        private void label1_Click(object senderEventArgs e)
        {
 
        }
 
        private void label2_Click(object senderEventArgs e)
        {
            convertCurrency();
        }
 
        private void label3_Click(object senderEventArgs 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(outnum6);
        }
    }
}

Cuplikan Hasil



Komentar

Postingan populer dari blog ini

Dataset TA Rihan Farih Bunyamin - CSM

PBKK A - Tugas 3