Slahkan didownload di link berikut download
Wednesday, February 22, 2012
Tuesday, December 13, 2011
program interface jam dalam c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication33
{
interface jamdunia
{
void jam();
}
class denpasar : jamdunia
{
public void jam()
{
string a = DateTime.Now.ToLongTimeString();
Console.WriteLine("jam sekarang di denpasar adalah {0}",a);
}
}
class london : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-8).ToLongTimeString();
Console.WriteLine("jam sekarang di london adalah {0}",a);
}
}
class greenwich : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-8).ToLongTimeString();
Console.WriteLine("jam sekarang di greenwich adalah {0}", a);
}
}
class washington : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-14).ToLongTimeString();
Console.WriteLine("jam sekarang di london adalah {0}", a);
}
}
class Program
{
static void Main(string[] args)
{
jamdunia waktu;
Console.WriteLine("pilih lokasi = ");
Console.WriteLine(" 1. denpasar");
Console.WriteLine(" 2. greenwich");
Console.WriteLine(" 3. london");
Console.WriteLine(" 4. washington");
Console.Write(" Pilih ");
int a = int.Parse(Console.ReadLine());
if (a == 1)
{
waktu = new denpasar();
waktu.jam();
}
else
if (a == 2)
{
waktu = new greenwich();
waktu.jam();
}
else
if (a == 3)
{
waktu = new london();
waktu.jam();
}
else
if (a == 4)
{
waktu = new washington();
waktu.jam();
}
else
Console.WriteLine("pilihan salah");
}
}
}
program interface tanggal dan jam versi 2 dalam c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication33
{
interface jamdunia
{
void jam();
}
class denpasar : jamdunia
{
public void jam()
{
string a = DateTime.Now.ToString();
string[] b = a.Split(' ');
Console.WriteLine("waktu denpasar = ");
Console.WriteLine("tanggal = {0}", b[0]);
Console.WriteLine("jam = {0}", b[1]);
}
}
class london : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-08).ToString();
string[] b = a.Split(' ');
Console.WriteLine("waktu london = ");
Console.WriteLine("tanggal = {0}", b[0]);
Console.WriteLine("jam = {0}", b[1]);
}
}
class greenwich : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-08).ToString();
string[] b = a.Split(' ');
Console.WriteLine("waktu greenwich = ");
Console.WriteLine("tanggal = {0}", b[0]);
Console.WriteLine("jam = {0}", b[1]);
}
}
class washington : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-14).ToString();
string[] b = a.Split(' ');
Console.WriteLine("waktu washington = ");
Console.WriteLine("tanggal = {0}", b[0]);
Console.WriteLine("jam = {0}", b[1]);
}
}
class Program
{
static void Main(string[] args)
{
jamdunia waktu;
Console.WriteLine("pilih lokasi = ");
Console.WriteLine(" 1. denpasar");
Console.WriteLine(" 2. greenwich");
Console.WriteLine(" 3. london");
Console.WriteLine(" 4. washington");
Console.Write(" Pilih ");
int a = int.Parse(Console.ReadLine());
if (a == 1)
{
waktu = new denpasar();
waktu.jam();
}
else
if (a == 2)
{
waktu = new greenwich();
waktu.jam();
}
else
if (a == 3)
{
waktu = new london();
waktu.jam();
}
else
if (a == 4)
{
waktu = new washington();
waktu.jam();
}
else
Console.WriteLine("pilihan salah");
}
}
}
program interface tanggal dan jam dalam c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication33
{
interface jamdunia
{
void jam();
}
class denpasar : jamdunia
{
public void jam()
{
string a = DateTime.Now.ToString();
Console.WriteLine("waktu denpasar = {0} ", a);
}
}
class london : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-08).ToString();
Console.WriteLine("waktu london = {0} ", a);
}
}
class greenwich : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-08).ToString();
Console.WriteLine("waktu greenwich = {0} ", a);
}
}
class washington : jamdunia
{
public void jam()
{
string a = DateTime.Now.AddHours(-14).ToString();
Console.WriteLine("waktu washington = {0} ", a);
}
}
class Program
{
static void Main(string[] args)
{
jamdunia waktu;
Console.WriteLine("pilih lokasi = ");
Console.WriteLine(" 1. denpasar");
Console.WriteLine(" 2. greenwich");
Console.WriteLine(" 3. london");
Console.WriteLine(" 4. washington");
Console.Write(" Pilih ");
int a = int.Parse(Console.ReadLine());
if (a == 1)
{
waktu = new denpasar();
waktu.jam();
}
else
if (a == 2)
{
waktu = new greenwich();
waktu.jam();
}
else
if (a == 3)
{
waktu = new london();
waktu.jam();
}
else
if (a == 4)
{
waktu = new washington();
waktu.jam();
}
else
Console.WriteLine("pilihan salah");
}
}
}
Thursday, December 8, 2011
procedure bubble sort versi boolean dalam notasi algoritmik
procedure bubbleshort (m:array[1..20] of integer, input n:integer)
{Mengurutkan isi dari tabel m dari kecil ke besar dengan metode pengurutan bubble short}
Kamus
i,j,temp:integer {variable perulangan}
cek:boolean
Algoritma
i <- 1
cek <- true
while (i <= n-1) and (cek=true) do
cek <- false
for j <- n downto i+1
if m[j] < m[j-1] then
temp <- m[j]
m[j] <- m[j-1]
m[j-1] <- temp
cek <- true
endif
endfor
endwhile
i <- i+1
procedure bubble sort dalam notasi algoritmik
procedure bubbleshort (m:array[1..20] of integer, input n:integer)
{Mengurutkan isi dari tabel m dari kecil ke besar dengan metode pengurutan bubble short}
Kamus
i,j:integer {variable perulangan}
Algoritma
for i = 1 to n-1 do
for j = i+1 to n do
if m[j]< m[j+1] then
temp ← m[j]
m[j] ← m[j+1]
m[j+1] ← temp
end if
end for
end for
procedure selection sort dalam notasi algoritmik
Procedure SelectionSort (data : array[1..100] of integer; input n:integer)
{ Mengurutkan data [1..100] dengan algoritma Selection Sort.}
Kamus
i, j, temp, min : integer
Algoritma:
for i= 1 to n-1 do {notasi for}
min ← i
for j = i+1 to n do
if data[min] > data[j] then
temp ← data[j]
endif
endfor
temp ← data[i]
data[i] ← data[j]
data[j] ← temp
end for
Tuesday, December 6, 2011
program student dengan generic class dalam C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication35
{
class student<T, C>
{
C name;
T grade;
public student(C name, T grade)
{
this.name = name;
this.grade= grade;
}
public override string ToString()
{
return string.Format(" name : {0} \n grade : {1} ", name,grade);
}
}
class Program
{
static void Main(string[] args)
{
student<int, string> s = new student<int, string>("budi", 1);
student<int, int> a = new student<int, int>(600, 1);
Console.WriteLine(s);
Console.WriteLine(a);
}
}
}
program saluran televisi versi 2 dengan C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication33
{
interface acaratv
{
void berita();
void olahraga();
void movie();
void hiburan();
}
class antv : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita antv");
}
public void olahraga()
{
Console.WriteLine("siaran lensa olah raga");
}
public void movie()
{
Console.WriteLine("siaran movie antv");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan antv");
}
}
class trans7 : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita trans7");
}
public void olahraga()
{
Console.WriteLine("siaran olah raga tran7");
}
public void movie()
{
Console.WriteLine("siaran boiskop trans7");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan trans7");
}
}
class rcti : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita rcti");
}
public void olahraga()
{
Console.WriteLine("siaran lensa olah rcti");
}
public void movie()
{
Console.WriteLine("siaran movie rcti");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan rcti");
}
}
class sctv : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita sctv");
}
public void olahraga()
{
Console.WriteLine("siaran olah raga sctv");
}
public void movie()
{
Console.WriteLine("siaran movie sctv");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan sctv");
}
}
class Program
{
static void Main(string[] args)
{
acaratv tv;
while (true)
{
Console.WriteLine("Program Acara TV");
Console.WriteLine("pilih saluran = ");
Console.WriteLine(" 1. ANTV");
Console.WriteLine(" 2. Trans7");
Console.WriteLine(" 3. RCTI");
Console.WriteLine(" 4. SCTV");
Console.WriteLine(" 5. exit");
Console.Write(" Pilih ");
int a = int.Parse(Console.ReadLine());
switch (a)
{
case 1:
{
tv = new antv();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
break;
}
case 2:
{
tv = new trans7();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
break;
}
case 3:
{
tv = new rcti();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
break;
}
case 4:
{
tv = new sctv();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
break;
}
case 5:
{
return;
}
}
}
}
}
}
program saluran televisi dengan C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication33
{
interface acaratv
{
void berita();
void olahraga();
void movie();
void hiburan();
}
class antv : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita antv");
}
public void olahraga()
{
Console.WriteLine("siaran lensa olah raga");
}
public void movie()
{
Console.WriteLine("siaran movie antv");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan antv");
}
}
class trans7 : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita trans7");
}
public void olahraga()
{
Console.WriteLine("siaran olah raga tran7");
}
public void movie()
{
Console.WriteLine("siaran boiskop trans7");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan trans7");
}
}
class rcti : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita rcti");
}
public void olahraga()
{
Console.WriteLine("siaran lensa olah rcti");
}
public void movie()
{
Console.WriteLine("siaran movie rcti");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan rcti");
}
}
class sctv : acaratv
{
public void berita()
{
Console.WriteLine("siaran berita sctv");
}
public void olahraga()
{
Console.WriteLine("siaran olah raga sctv");
}
public void movie()
{
Console.WriteLine("siaran movie sctv");
}
public void hiburan()
{
Console.WriteLine("siaran hiburan sctv");
}
}
class Program
{
static void Main(string[] args)
{
acaratv tv;
Console.WriteLine("Program Acara TV");
Console.WriteLine("pilih saluran = ");
Console.WriteLine(" 1. ANTV");
Console.WriteLine(" 2. Trans7");
Console.WriteLine(" 3. RCTI");
Console.WriteLine(" 4. SCTV");
Console.Write(" Pilih ");
int a = int.Parse(Console.ReadLine());
if (a == 1)
{
tv = new antv();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
}
else
if (a == 2)
{
tv = new trans7();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
}
else
if (a == 3)
{
tv = new rcti();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
}
else
if (a == 4)
{
tv = new sctv();
tv.berita();
tv.olahraga();
tv.movie();
tv.hiburan();
}
else
Console.WriteLine("tidak ada saluran");
}
}
}
program operator seluler dalam C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication33
{
interface simcard
{
void call();
void sms();
}
class xl : simcard
{
public void call()
{
Console.WriteLine("calling from xl");
}
public void sms()
{
Console.WriteLine("sms from xl");
}
}
class telkomsel : simcard
{
public void call()
{
Console.WriteLine("calling from telkomsel");
}
public void sms()
{
Console.WriteLine("sms from telkomsel");
}
}
class Program
{
static void Main(string[] args)
{
simcard sim;
Console.WriteLine("pilih operator = ");
Console.WriteLine(" 1. xl");
Console.WriteLine(" 2. telkomsel");
Console.Write(" Pilih ");
int a = int.Parse(Console.ReadLine());
if (a == 1)
{
sim = new xl();
sim.call();
sim.sms();
}
else
if (a==2)
{
sim = new telkomsel();
sim.call();
sim.sms();
}
}
}
}
program bank inheritance versi 3 dalam c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
abstract class bank
{
static int amount;
public void deposit()
{
int amt = int.Parse(Console.ReadLine());
amount += amt;
}
public void withdraw()
{
int amt = int.Parse(Console.ReadLine());
if (amount < amt)
{
Console.WriteLine("Saldo Kurang");
}
else
{
amount -= amt;
}
}
public void cek_saldo()
{
Console.WriteLine("Jumlah Saldo Anda = {0}", amount);
}
}
class BNI : bank
{
public void jumlah_rekening_dari_nasabah()
{
base.deposit();
base.withdraw();
base.cek_saldo();
}
}
class Program
{
static void Main(string[] args)
{
Console.Write("Jumlah Nasabah = ");
int n_nasabah = int.Parse(Console.ReadLine());
BNI[] nasabah = new BNI[n_nasabah + 1];
for (int i = 1; i <= n_nasabah; i++)
{
nasabah[i] = new BNI();
}
while (true)
{
Console.WriteLine("Pilihan : ");
Console.WriteLine(" 1. Menabung");
Console.WriteLine(" 2. Mengambil Uang");
Console.WriteLine(" 3. Cek_Saldo");
Console.WriteLine(" 4. keluar");
Console.Write("Pilih : ");
int pilih = int.Parse(Console.ReadLine());
int no_rek;
switch (pilih)
{
case 1:
{
Console.Write("Nomor Rekening Anda : ");
no_rek = int.Parse(Console.ReadLine());
Console.Write("Jumlah Uang ");
BNI obj = new BNI();
obj.deposit();
break;
}
case 2:
{
Console.Write("Nomor Rekening Anda : ");
no_rek = int.Parse(Console.ReadLine());
Console.Write("Jumlah Uang ");
BNI obj = new BNI();
obj.withdraw();
break;
}
case 3:
{
Console.Write("Nomor Rekening Anda : ");
no_rek = int.Parse(Console.ReadLine());
BNI obj = new BNI();
obj.cek_saldo();
break;
}
case 4:
{
return;
}
}
}
}
}
}
program bank inheritance versi 2 dalam c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
abstract class bank
{
private int amount;
public void deposit(int amt)
{
amount += amt;
}
public void withdraw(int amt)
{
if (amount < amt)
{
Console.WriteLine("Saldo Kurang");
}
else
{
amount -= amt;
}
}
public void cek_saldo()
{
Console.WriteLine("Jumlah Saldo Anda = {0}", amount);
}
}
class BNI : bank
{
private int temp;
public void a1()
{
base.deposit(temp);
base.withdraw(temp);
base.cek_saldo();
}
}
class Program
{
static void Main(string[] args)
{
Console.Write("Jumlah Nasabah = ");
int n_nasabah = int.Parse(Console.ReadLine());
BNI[] nasabah = new BNI[n_nasabah + 1];
for (int i = 1; i <= n_nasabah; i++)
{
nasabah[i] = new BNI();
}
while (true)
{
Console.WriteLine("Pilihan : ");
Console.WriteLine(" 1. Menabung");
Console.WriteLine(" 2. Mengambil Uang");
Console.WriteLine(" 3. Cek_Saldo");
Console.WriteLine(" 4. keluar");
Console.Write("Pilih : ");
int pilih = int.Parse(Console.ReadLine());
int no_rek;
int jumlah;
switch (pilih)
{
case 1:
{
Console.Write("Nomor Rekening Anda : ");
no_rek = int.Parse(Console.ReadLine());
Console.Write("Jumlah Uang ");
jumlah = int.Parse(Console.ReadLine());
nasabah[no_rek].deposit(jumlah);
break;
}
case 2:
{
Console.Write("Nomor Rekening Anda : ");
no_rek = int.Parse(Console.ReadLine());
Console.Write("Jumlah Uang ");
jumlah = int.Parse(Console.ReadLine());
nasabah[no_rek].withdraw(jumlah);
break;
}
case 3:
{
Console.Write("Nomor Rekening Anda : ");
no_rek = int.Parse(Console.ReadLine());
nasabah[no_rek].cek_saldo();
break;
}
case 4:
return;
}
}
}
}
}
Monday, December 5, 2011
Counting Sort dalam notasi algoritmik
Procedure CountingSort (Input/output T:array [1..N] of integer)
{Mengurutkan Tabel T integer [1..N] dengan pencacahan, dimana range atau rentang nilainya [1..k] dengan hasil akhir T terurut menaik , dengan asumsi:Nilai N (jumlah elemen T) dan k diketahui
Asumsi : Nilai N (jumlah elemen T) dan k diketahui, rentang nilai untuk elemen T integer antara 1..k }
Kamus
C : array [1..k] of integer {Tabel array pencacahan}
i, j : Integer {indek perulangan}
c : Integer {jumlah elemen T yang sudah diisi pada pembentukank kembali}
Algoritma
for i = 1 to k do {Loop 1}
C[ i ] <-- 0;
endfor
for i = 1 to N do {Loop 2}
C[ T[ i ] ] <-- C[ T [ i ] ] + 1
endfor
c <-- 0
for i = 1 to k do {Loop 3}
if C[ i ] <> 0 then
for j = 1 to C[ i ] do {Loop 4}
c <--c + 1
T[c] <-- i
endfor;
endif;
endfor;
{Mengurutkan Tabel T integer [1..N] dengan pencacahan, dimana range atau rentang nilainya [1..k] dengan hasil akhir T terurut menaik , dengan asumsi:Nilai N (jumlah elemen T) dan k diketahui
Asumsi : Nilai N (jumlah elemen T) dan k diketahui, rentang nilai untuk elemen T integer antara 1..k }
Kamus
C : array [1..k] of integer {Tabel array pencacahan}
i, j : Integer {indek perulangan}
c : Integer {jumlah elemen T yang sudah diisi pada pembentukank kembali}
Algoritma
for i = 1 to k do {Loop 1}
C[ i ] <-- 0;
endfor
for i = 1 to N do {Loop 2}
C[ T[ i ] ] <-- C[ T [ i ] ] + 1
endfor
c <-- 0
for i = 1 to k do {Loop 3}
if C[ i ] <> 0 then
for j = 1 to C[ i ] do {Loop 4}
c <--c + 1
T[c] <-- i
endfor;
endif;
endfor;
bucket Sort dalam notasi algoritmik
Algoritma Bucket Sort
Procedure BucketSort ( Input/Output T: array[1..n] of integer, b: integer Output T: Array[1..n], Input n,max_n:integer)
{procedure untuk mengurutkan T array secara ascending, dengan asumsi jumlah data dan nilai terbesar diketahui}
Kamus
range : integer {rentang nilai bucket}
x,y, i, j : integer
baris, kolom : integer
isi_bucket : array [1..b] of integer {penyimpan nilai isi tiap bucket}
lengh_bucket : array [1..n] of integer {kapasitas bucket menyimpan nilai}
bucket : array [1..b] of lengh_bucket {bucket; kumpulan lengh_bucket}
Algoritma
x ß max_n div b
y ß max_n mod b
if (y > 0) then
range ß x + 1
else {menentukan interval @bucket}
range ß x
endif
for i = 1 to b do
isi_bucket[i] ß 0 {inisialisasi isi @bucket = 0}
endfor
for i = 1 to n do
x ß T[i] div range
y ß T[i] mod range
if (y > 0) then
x ß x + 1 {loop; membagi nilai T ke dalam @bucket}
endif
isi_bucket[x] ß isi_bucket[x] + 1
baris ß x
kolom ß isi_bucket[x]
bucket[m, n] ßT[i]
endfor
for i = 1 to b do
{pengurutan @ bucket dengan algoritma pengurutan tertentu}
Endfor
n ß 1
for i = 1 to b do
for j = 1 to isi_bucket[i] do
T[n] ß bucket[i,j] {penggabungan bucket}
n ß n + 1
endfor
endfor
Subscribe to:
Posts (Atom)