Modul 1. lat2

package latihan2;

/**
 *
 * @author Ahmad Rizal Abidin, M.Kom
 */
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class variabel{
    String Nofak ="";
    String Tgl ="";
    String Nm ="";
    String Alm ="";
    String jum ="";
}
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        BufferedReader InputD = new BufferedReader (new InputStreamReader(System.in));
        variabel Faktur=new variabel();
        System.out.println("Input Nofak : ");
        try{
            Faktur.Nofak = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
        System.out.println("Input Tanggal : ");
        try{
            Faktur.Tgl = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
        System.out.println("Input Nama : ");
        try{
            Faktur.Nm = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
        System.out.println("Alamat : ");
        try{
            Faktur.Alm = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
        System.out.println("Jumlah : ");
        try{
            Faktur.jum = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
        int Jumlah =Integer.valueOf(Faktur.jum).intValue();
        //mendefinisikan Variabel Array
        String []kdBrg = new String[Jumlah];
        String []nmBrg = new String[Jumlah];
        String []hrgBrg = new String[Jumlah];
        String []jumBrg = new String[Jumlah];
        String []jumHrg = new String[Jumlah];
        

        for (int i = 0;i < Jumlah;i++)
        {
        System.out.println("Input Kode Barang : ");
        try{
            kdBrg[i] = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
        
        System.out.println("Input Nama Barang :");
        try{
            nmBrg[i] = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
     
        System.out.println("Input Harga :");
        try{
            hrgBrg[i] = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }

        System.out.println("Jumlah Barang :");
        try{
            jumBrg[i] = InputD.readLine();
        }catch(IOException e){
            System.out.println("Error");
        }
        
                
        }
        System.out.println("Faktur Pembelian Barang");
        System.out.println("Nomor Faktur   :"+Faktur.Nofak);
        System.out.println("Tanggal        :"+Faktur.Tgl);
        System.out.println("Nama Pembeli   :"+Faktur.Nm);
        System.out.println("Alamat Pembeli :"+Faktur.Alm);
        for (int i=0;i<Jumlah;i++)
        {
        int hargaBarang = Integer.valueOf(hrgBrg[i]).intValue(); 
        int jumlahBarang = Integer.valueOf(jumBrg[i]).intValue();
        //int jumlahHarga = Integer.valueOf(jumHrg[i]).intValue();
        int jumlahHarga = hargaBarang * jumlahBarang;    
            System.out.println(kdBrg[i]+" "+nmBrg[i]+" "+hrgBrg[i]+"  "+jumBrg[i]+" "+jumlahHarga);
            
        }
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: