Wednesday, September 28, 2011
Program Accounting Sederhana
import java.io.*;
class Personal
{
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static int MENU() throws Exception
{
System.out.println("1. Transaksi");
System.out.println("2. Lihat Saldo");
System.out.println("3. Lihat Detail Transaksi");
System.out.println("4. Exit");
System.out.print("Pilihan : ");
return Integer.parseInt(in.readLine());
}
public static void main(String[] args) throws Exception
{
int saldo = 0;
int count = 0;
Transaksi[] trans = new Transaksi[100];
do
{
int pil = MENU();
if(pil == 1)
{
trans[count] = new Transaksi();
System.out.print("Tanggal : ");
trans[count].setTgl(in.readLine());
System.out.print("Nominal : ");
trans[count].setNominal(Integer.parseInt(in.readLine()));
System.out.print("Keterangan : ");
trans[count].setKet(in.readLine());
System.out.print("Status : ");
trans[count].setStatus(in.readLine());
if(trans[count].getStatus().equals("debet"))
{
saldo += trans[count].getNominal();
}
else
{
saldo -= trans[count].getNominal();
}
count ++;
}
else if(pil == 2)
{
System.out.println("Saldo : " + saldo);
}
else if(pil == 3)
{
System.out.println("Tanggal\t\t\t\tNominal\t\tKeterangan\tStatus");
for(int i=0;i<count;i++)
{
System.out.println(trans[i].getTgl() + "\t\t" + trans[i].getNominal() + "\t\t" + trans[i].getKet() + "\t\t" + trans[i].getStatus());
}
}
else if(pil == 4)
{
System.exit(0);
}
System.out.println();
}
while(true);
}
}
class Transaksi
{
private String tgl;
private int nominal;
private String ket;
private String status;
public Transaksi()
{
tgl = "";
nominal = 0;
ket = "";
status = "";
}
public void setTgl(String tgl)
{
this.tgl = tgl;
}
public String getTgl()
{
return tgl;
}
public void setNominal(int nominal)
{
this.nominal = nominal;
}
public int getNominal()
{
return nominal;
}
public void setKet(String ket)
{
this.ket = ket;
}
public String getKet()
{
return ket;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
}
class Personal
{
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static int MENU() throws Exception
{
System.out.println("1. Transaksi");
System.out.println("2. Lihat Saldo");
System.out.println("3. Lihat Detail Transaksi");
System.out.println("4. Exit");
System.out.print("Pilihan : ");
return Integer.parseInt(in.readLine());
}
public static void main(String[] args) throws Exception
{
int saldo = 0;
int count = 0;
Transaksi[] trans = new Transaksi[100];
do
{
int pil = MENU();
if(pil == 1)
{
trans[count] = new Transaksi();
System.out.print("Tanggal : ");
trans[count].setTgl(in.readLine());
System.out.print("Nominal : ");
trans[count].setNominal(Integer.parseInt(in.readLine()));
System.out.print("Keterangan : ");
trans[count].setKet(in.readLine());
System.out.print("Status : ");
trans[count].setStatus(in.readLine());
if(trans[count].getStatus().equals("debet"))
{
saldo += trans[count].getNominal();
}
else
{
saldo -= trans[count].getNominal();
}
count ++;
}
else if(pil == 2)
{
System.out.println("Saldo : " + saldo);
}
else if(pil == 3)
{
System.out.println("Tanggal\t\t\t\tNominal\t\tKeterangan\tStatus");
for(int i=0;i<count;i++)
{
System.out.println(trans[i].getTgl() + "\t\t" + trans[i].getNominal() + "\t\t" + trans[i].getKet() + "\t\t" + trans[i].getStatus());
}
}
else if(pil == 4)
{
System.exit(0);
}
System.out.println();
}
while(true);
}
}
========================================================================
class Transaksi
{
private String tgl;
private int nominal;
private String ket;
private String status;
public Transaksi()
{
tgl = "";
nominal = 0;
ket = "";
status = "";
}
public void setTgl(String tgl)
{
this.tgl = tgl;
}
public String getTgl()
{
return tgl;
}
public void setNominal(int nominal)
{
this.nominal = nominal;
}
public int getNominal()
{
return nominal;
}
public void setKet(String ket)
{
this.ket = ket;
}
public String getKet()
{
return ket;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
}
Labels:
Pemograman Berbasis Objek (PBO)
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment