Berikut tutorial membuat perhitungan sederhana dengan C# oleh teman kita http://octtenz.wordpress.com
Kemudian pada bagian MainForm.cs ketikkan kode berikut ( atau copy paste sajalah
):
012 | using System.Collections.Generic; |
015 | using System.Windows.Forms; |
020 | /// Description of MainForm. |
022 | public partial class MainForm : Form |
038 | InitializeComponent(); |
040 | cmbCompFreq.Items.Add(Compound.Daily); |
041 | cmbCompFreq.Items.Add(Compound.Monthly); |
042 | cmbCompFreq.Items.Add(Compound.Quarterly); |
043 | cmbCompFreq.Items.Add(Compound.SemiAnnually); |
044 | cmbCompFreq.Items.Add(Compound.Annually); |
045 | cmbCompFreq.SelectedItem = cmbCompFreq.Items[0]; |
051 | private void BtnCalculateClick( object sender, System.EventArgs e) |
053 | decLabelMax = 10000000000M; |
056 | double jumlahAwal = ( double ) nupJumlahAwal.Value; |
057 | double rate = ( double ) nupInterestRate.Value; |
058 | int years = ( int ) nupYears.Value; |
059 | Compound calcFrequency = (Compound) cmbCompFreq.SelectedItem; |
062 | decimal totalValue = 0; |
069 | switch ( calcFrequency ) { |
072 | double dailyRate = rate / 365; |
074 | periods = years * 365; |
076 | jumlahAwal = jumlahAwal * Math.Pow((1 + dailyRate),( double )periods); |
078 | case Compound.Monthly: |
080 | double monthlyRate = rate / 12; |
082 | periods = years * 12; |
084 | jumlahAwal = jumlahAwal * Math.Pow((1 + monthlyRate),( double )periods); |
086 | case Compound.Quarterly: |
088 | double quarterlyRate = rate / 4; |
092 | jumlahAwal = jumlahAwal * Math.Pow((1 + quarterlyRate),( double )periods); |
094 | case Compound.SemiAnnually: |
096 | double semiAnnualRate = rate / 2; |
099 | jumlahAwal = jumlahAwal * Math.Pow((1 + semiAnnualRate),( double )periods); |
101 | case Compound.Annually: |
103 | double annualRate = rate; |
107 | jumlahAwal = jumlahAwal * Math.Pow((1 + annualRate),( double )periods); |
111 | MessageBox.Show( this , "Ada Error" ); |
114 | totalValue = ( decimal ) jumlahAwal; |
117 | if ( totalValue <= decLabelMax ) { |
119 | lblTotalTabungan.Text = String.Format( "Rp. {0:###,###.##}" , totalValue); |
123 | MessageBox.Show( "Jumlah melebihi nilai maximum" ); |
Apabila tidak ada masalah, maka apabila di run akan muncul tampilan :
Semoga bermanfaat…
{ 1 komentar... Views All / Post Comment! }
ini sama di visual bassic . net 2012 sama ngga coding nya?
Posting Komentar