Senin, 19 September 2011

Tugas 2 - OOP (Object Oriented Programming)


/**
*@author rifai
*@akuntasi sederhana
*/
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AkuntansiSederhana
{
private static int counter=0;
private Date tgl;
private boolean debet;
private int jumlah;
private String ket;


public void setCounter(int counter)
{
this.counter = counter;
}
public void setTgl(Date tgl)
{
this.tgl= tgl;
}
public void setDebet(boolean debet)
{
this.debet= debet;
}
public void setJumlah(int jumlah)
{
this.jumlah= jumlah;
}
public void setKet(String ket)
{
this.ket = ket;
}
public int getCounter()
{
return counter;
}
public Date getTgl()
{
return tgl;
}
public boolean getDebet()
{
return debet;
}
public int getJumlah()
{
return jumlah;
}
public String getKet()
{
return ket;
}
}

--------------------------------end program---------------------------------

/**
*@author rifai
*@akuntasi sederhana
*/
import java.io.*;
import java.util.Vector;
import java.text.SimpleDateFormat;
import java.util.Date;
class RunAkutansi
{
public static void main (String[]args)
throws IOException
{
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
AkuntansiSederhana akuntansi = new AkuntansiSederhana();
int b=0;
Vector dataku = new Vector ();
int pil=0;
boolean debetKredit;
int total=0;
int awal=0;
Date date = new Date();
SimpleDateFormat sdf;
sdf = new SimpleDateFormat("dd-MM-yyyy-hh-mmss");
do
{
System.out.println("++++++++++++++++++++++++++++++++++");
System.out.println("Menu Transaksi");
System.out.println("++++++++++++++++++++++++++++++++++");
System.out.println("1. Input Transksi");
System.out.println("2. Cetak Laporan");
System.out.println("3. Keluar");
System.out.print("Masukan Pilihan Anda : " );
pil = Integer.parseInt(br.readLine());
System.out.println();

if (pil == 1)
{
while (true)
{
System.out.print("Input Transaksi (y/n) ");
String item = br.readLine();
System.out.println();
if (item.equals("n"))
{
break;
}
else
{

System.out.println("Tgl : " + sdf.format(date));
akuntansi.setTgl(date);
dataku.addElement( sdf.format( akuntansi.getTgl() ));
System.out.print("Keterangan : ");
String ket = br.readLine();
akuntansi.setKet((ket));
dataku.addElement(akuntansi.getKet());

System.out.print("Debet/Kredit : ");
String dk = br.readLine();

if (dk.equals("debet"))
{
debetKredit = true;
}
else
{
debetKredit = false;
}
akuntansi.setKet((ket));
dataku.addElement(dk);

System.out.print("Nominal : ");
String jumlah = br.readLine();
akuntansi.setJumlah(Integer.parseInt(jumlah));
int h = akuntansi.getJumlah();

if (debetKredit==true)
{
dataku.addElement("+" + akuntansi.getJumlah());
total = (total + akuntansi.getJumlah());
}
else
{
dataku.addElement("-" + akuntansi.getJumlah());
total = (total - akuntansi.getJumlah());
}



}
System.out.println();
}
}
else if (pil == 2)
{
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("Laporan Pemasukan dan Pengeluaran Kas Harian");
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("Saldo Awal : " + awal);
System.out.println("-------------------------------------------------------------");
System.out.println("Tanggal Keterangan D/K Nominal");
System.out.println("-------------------------------------------------------------");

int l=0;
for (int c=0 ; c < dataku.size() ; c++)
{
l=l+1;
if (l==5)
{
l=1;
System.out.println();
}

System.out.print(dataku.elementAt(c) + " ");
}
System.out.println();
System.out.println("------------------------------------------------------------");
System.out.println("Saldo Akhir : " + total);
awal = total;
System.out.println();
}
else if (pil == 3)
{
System.exit(0);
}
}
while (pil != 3);
}
}

Tidak ada komentar:

Posting Komentar

 
Copyright 2011 @ learning for sharing!