TUGAS 2 ( PBO) personal accounting


PERTEMUAN 2 (TRANSAKSI = VIEW SALDO, VIEW TRANSAKSI, ADD TRANSAKSI)

import java.util.Date;
/**
 * Write a description of class Transaksi here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
public class Transaksi
{
    // instance variables - replace the example below with your own
  
    private String nama;
    private Date tgl;
    private int jumlah;
    public long saldoAwal;
    private long saldoAkhir;
    private String NamaTransaksi;
    public String UangMasukKeluar;
   
   
    /**
     * Constructor for objects of class Transaksi
     */
 
    public Transaksi(String nama, long saldoAwal)
    {
        // initialise instance variables
       
        this.nama=nama;
        this.saldoAwal=saldoAwal;
    }
   

    /**
     * An example of a method - replace this comment with your own
     *
     * @param  y   a sample parameter for a method
     * @return     the sum of x and y
     */
   
   
    public void addTransaksi(int jumlah,String UangMasukKeluar, String NamaTransaksi)
    {
        if (UangMasukKeluar=="uang masuk")
        saldoAkhir = saldoAwal + jumlah;
        else if (UangMasukKeluar=="uang keluar")
        saldoAkhir = saldoAwal - jumlah; 
        this.UangMasukKeluar=UangMasukKeluar;
        this.jumlah=jumlah;
        this.NamaTransaksi=NamaTransaksi;
    }
   
    public void viewTransaksi()
    {
        // put your code here
        System.out.println ("Hello"+" "+this.nama+" "+"Daftar Transaksi Anda Adalah :");
        System.out.println ("SALDO AWAL =" + " " +this.saldoAwal);
        System.out.println (this.NamaTransaksi +" "+ this.UangMasukKeluar +" "+ this.jumlah);
        System.out.println ("SALDO AKHIR =" + " "+this.saldoAkhir);
        saldoAwal=saldoAkhir;
    }
    public void viewSaldo()
    {
        System.out.println ("Saldo Anda Saat ini adalah : " + " "+this.saldoAkhir);
    }
}






1.            View Saldo












2.  Add Transaksi












3.  View Transaksi



















 (REKENING = SETOR TUNAI, CETAK INFO, TARIK TUNAI)

/**
 * Write a description of class Rekening here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
public class Rekening
{
    // instance variables - replace the example below with your own
    private int MIN_SETOR = 50;
    private int MIN_TARIK = 100;
    private String noRek;
    private String nama;
    private long saldo;

    /**
     * Constructor for objects of class Rekening
     */
    public Rekening(String noRek, String nama, long saldo)
    {
        // initialise instance variables
        this.nama=nama;
        this.noRek=noRek;
        this.saldo=saldo;
    }

    /**
     * An example of a method - replace this comment with your own
     *
     * @param  y   a sample parameter for a method
     * @return     the sum of x and y
     */
    public void setorTunai(long jml)
    {
        // put your code here
        if (jml>=MIN_SETOR)
        saldo +=jml;
        else
        System.out.println("Minimum Setor = " + MIN_SETOR);
    }
   
    public void cetakInfo()
    {
        System.out.println (this.nama);
        System.out.println (this.noRek);
        System.out.println (this.saldo);
    }
   
    public void tarikTunai(long jml)
    {
        if (jml>=MIN_TARIK)
        saldo -=jml;
        else
        System.out.println ("Minimum Tarik =" +MIN_TARIK);
    }
}
1. Setor Tunai














2. Tarik Tunai












 
3. View