Rabu, 16 November 2011

pemberitahuan


gubug algoritma telah dialihkan ke alamat
http://gubugalgoritma.blogspot.com/

thanx yoo

Selasa, 15 November 2011

program bank dalam c#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public class bank
    {
        private int amount;
        private static int total;
        public void deposit(int amt)
        {
            amount += amt;
            total = total + amt;
        }
        public void withdraw(int amt)
        {
            if (amount < amt)
            {
                Console.WriteLine("Saldo Kurang");
            }
            else
            {
                amount -= amt;
                total = total - amt;
            }
        }
        public void cek_saldo()
        {
            Console.WriteLine("Jumlah Saldo Anda = {0}", amount);
        }
        public static void show_total()
        {
            Console.WriteLine("Jumlah Uang di Bank =  {0}", total);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Jumlah Nasabah = ");
            int n_nasabah = int.Parse(Console.ReadLine());
            bank[] nasabah = new bank[n_nasabah + 1];
            for (int i = 1; i <= n_nasabah; i++)
            {
                nasabah[i] = new bank();
            }

            while (true)
            {
                Console.WriteLine("Pilihan : ");
                Console.WriteLine("     1. Menabung");
                Console.WriteLine("     2. Mengambil Uang");
                Console.WriteLine("     3. Cek_Saldo");
                Console.WriteLine("     4. Cek_saldo_bank");
                Console.WriteLine("     5. 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:
                        {
                            bank.show_total();
                            Console.WriteLine();
                            break;
                        }
                    case 5:
                        return;
                }
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public class bank
    {
        private int amount;
        private static int total;
        public void deposit(int amt)
        {
            amount += amt;
            total = total + amt;
        }
        public void withdraw(int amt)
        {
            if (amount < amt)
            {
                Console.WriteLine("Saldo Kurang");
            }
            else
            {
                amount -= amt;
                total = total - amt;
            }
        }
        public void cek_saldo()
        {
            Console.WriteLine("Jumlah Saldo Anda = {0}", amount);
        }
        public static void show_total()
        {
            Console.WriteLine("Jumlah Uang di Bank =  {0}", total);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Jumlah Nasabah = ");
            int n_nasabah = int.Parse(Console.ReadLine());
            bank[] nasabah = new bank[n_nasabah + 1];
            for (int i = 1; i <= n_nasabah; i++)
            {
                nasabah[i] = new bank();
            }

            while (true)
            {
                Console.WriteLine("Pilihan : ");
                Console.WriteLine("     1. Menabung");
                Console.WriteLine("     2. Mengambil Uang");
                Console.WriteLine("     3. Cek_Saldo");
                Console.WriteLine("     4. Cek_saldo_bank");
                Console.WriteLine("     5. 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:
                        {
                            bank.show_total();
                            Console.WriteLine();
                            break;
                        }
                    case 5:
                        return;
                }
            }
        }
    }
}

Rabu, 09 November 2011

mencari niali terkecil array 2 dimensi

program matiks;


uses wincrt;

type
tab=record
kolom:integer;
baris:integer;
bil:integer;
end;

type
arin=array [1..100] of integer;

procedure min(b:arin;m,n:integer;var c:tab);
var
i,j,domp,temp:integer;
begin
domp:=b[1];
c.baris:=1;
c.kolom:=1;
for i:=1 to m do
begin
for j:= 1 to n do
begin
if domp>=b[j] then
begin
domp:=b[j];
c.baris:=i;
c.kolom:=j;
end;
end;
end;
c.bil:=domp;
end;


var
a:arin;
i,j,m,n,x:integer;
domp:tab;

begin
write('masukan jumlah baris : ');readln(n);
write('masukan jumlah kolom : ');readln(m);
for i:=1 to m do
begin
for j:= 1 to n do
begin
write('a[',i,',',j,'] : ');readln(a[j]);
end;
end;
writeln;
min(a,m,n,domp);
writeln('jadi bilangan terkecil adalah : ',domp.bil,' berada di a[',domp.baris,',',domp.kolom,']');
end.

mencari bilangan terkecil dalam array 2 dimensi

program matiks;

uses wincrt;

type
arin=array [1..100] of integer;

function min(b:arin;m,n:integer):integer;
var
i,j,domp:integer;
begin
domp:=b[1];
for i:=1 to m do
begin
for j:= 1 to n do
begin
if domp>=b[j] then
domp:=b[j];
end;
end;
min:=domp;
end;


var
a:arin;
i,j,m,n,x,domp:integer;

begin
write('masukan jumlah baris : ');readln(n);
write('masukan jumlah kolom : ');readln(m);
for i:=1 to m do
begin
for j:= 1 to n do
begin
write('a[',i,',',j,'] : ');readln(a[j]);
end;
end;
domp:=min(a,m,n);
writeln('jadi bilangan bilangan terkecil adalah ',domp);
end.

menghitung nilai 4 bilangan dalam pascal

program min_4bil;

uses wincrt;

function min2(a,b:integer):integer;
var
x : integer;

begin
     if a > b then
     x:=a
     else
     x:=b;
     min2:=x;
end;

var
a,b,c,d,x,y,z:integer;

begin
readln(a);
readln(b);
readln(c);
readln(d);
x:=min2(a,b);
y:=min2(c,d);
z:=min2(x,y);
writeln('nilai max = ',z);
end.