Jumat, 22 November 2013

Program Mesin Kasir

ayoooo baca!!!!

Mau tahu caranya membuat program mesin kasir???

awalnya, kamu harus buat flowchart,,
seperti apa sih flowchart itu??
lihat di bawaah


selanjutnya kita lanjut ke pseudocode ^^
#SEMANGAT

Algoritma mesinkasir
{Algoritma untuk perhitungan mesin kasir}
Deklarasi
Kodebarang1,namabarang1="",Kodebarang2,namabarang2=" ",Kodebarang3,namabarang3=" ", Kodebarang4,namabarang4=" " : String
Harga1=0,Hargatotal1=0,harga2=0,Hargatotal2,harga3=0,Hargatotal3,harga4=0, Hargatotal4, Jumlahbarang1,Jumlahbarang2,Jumlahbarang3,Jumlahbarang4 : int
deskripsi
begin,
read : Kodebarang1;

if(Kodebarang1.equals("HHH")){
namabarang1=" HANDPHONE ";
harga1=2500000;}
else
if(Kodebarang1.equals("LLL")){
namabarang1=" LAPTOP ";
harga1=7000000;}
else
if(Kodebarang1.equals("TTT")){
namabarang1=" TABLET ";
harga1=4500000;}
else
if(Kodebarang1.equals("VVV")){
namabarang1=" TELEVISI ";
harga1=6000000;}
else
if(Kodebarang1.equals("RRR")){
namabarang1=" RADIO ";
harga1=500000;}
else
Hargatotal1=harga1*Jumlahbarang1;
endif
          read: Kodebarang2;      
if(Kodebarang2.equals("HHH")){
namabarang2=" HANDPHONE ";
harga2=2500000;}
else
if(Kodebarang2.equals("LLL")){
namabarang2=" LAPTOP ";
harga2=7000000;}
else
if(Kodebarang2.equals("TTT")){
namabarang2=" TABLET ";
harga2=4500000;}
else
if(Kodebarang2.equals("VVV")){
namabarang2=" TELEVISI ";
harga2=6000000;}
else
if(Kodebarang2.equals("RRR")){
namabarang2=" RADIO ";
harga2=500000;}
else
Hargatotal2=harga2*Jumlahbarang2;
endif
          read: Kodebarang3;      
if(Kodebarang3.equals("HHH")){
namabarang3=" HANDPHONE ";
harga3=2500000;}
else
if(Kodebarang3.equals("LLL")){
namabarang3=" LAPTOP ";
harga3=7000000;}
else
if(Kodebarang3.equals("TTT")){
namabarang3=" TABLET ";
harga3=4500000;}
else
if(Kodebarang3.equals("VVV")){
namabarang3=" TELEVISI ";
harga3=6000000;}
else
if(Kodebarang3.equals("RRR")){
namabarang3=" RADIO ";
harga3=500000;}
else
Hargatotal3=harga3*Jumlahbarang3;
end if
          read: Kodebarang4;      
if(Kodebarang4.equals("HHH")){
namabarang4=" HANDPHONE ";
harga4=2500000;}
else
if(Kodebarang4.equals("LLL")){
namabarang4=" LAPTOP ";
harga4=7000000;}
else
if(Kodebarang4.equals("TTT")){
namabarang4=" TABLET ";
harga4=4500000;}
else
if(Kodebarang4.equals("VVV")){
namabarang4=" TELEVISI ";
harga4=6000000;}
else
if(Kodebarang4.equals("RRR")){
namabarang4=" RADIO ";
harga4=500000;}
else
Hargatotal4=harga4*Jumlahbarang4;
endif

                  
write("No.");write(("Kode Barang"));write(("Nama Barang"));write("Harga Satuan");write("Jumlah");write("Harga");

write("1");write((Kodebarang1));write((namabarang1));write(harga1);write("_“+Jumlahbarang1+"_");write(Hargatotal1);

write("2");write((Kodebarang2));write((namabarang2));write(harga2);write(Jumlahbarang2); write(Hargatotal2);

write("3");write ((Kodebarang3));write((namabarang3));write(harga3); write(Jumlahbarang3); write(Hargatotal3);

write("4");write((Kodebarang4));write((namabarang4));write(harga4);write(Jumlahbarang4); write(Hargatotal4);


end

next....
ayo tulis koding kamuuu
bingung??
ini contohnya

package mesin;
import java.util.Scanner;

public class mesinkasir22 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner ya = new Scanner(System.in);
String kodebarang1,namabarang1="",kodebarang2,namabarang2=" ",kodebarang3,namabarang3=" ",kodebarang4,namabarang5=" ";
int harga1=0,hargatotal1=0,harga2=0,hargatotal2,harga3=0,hargatotal3,harga4,hargatotal4, jumlahbarang1,jumlahbarang2,jumlahbarang3,jumlahbarang4;
Scanner ok = new Scanner(System.in);
System.out.print("==================================");
System.out.println("");
System.out.println("         22 MINI MARKET");
System.out.println("==================================");
System.out.print("");
System.out.println("Daftar Barang :");
System.out.println("1. HANDPHONE (HHH)");
System.out.println("2. LAPTOP (LLL)");
System.out.println("3. TABLET (TTT)");
System.out.println("4. TELEVISI (VVV)");
System.out.println("5. RADIO (RRR)");
System.out.println ("Selamat Datang");
System.out.print ("Masukkan Kode Barang: ");
kodebarang1 = ya.nextLine();
System.out.print ("Masukkan Jumlah Barang: ");
jumlahbarang1 = ya.nextInt();
if(kodebarang1.equals("HHH")){
namabarang1=" HANDPHONE ";
harga1=2500000;}
else
if(kodebarang1.equals("LLL")){
namabarang1=" LAPTOP ";
harga1=7000000;}
else
if(kodebarang1.equals("TTT")){
namabarang1=" TABLET ";
harga1=4500000;}
else
if(kodebarang1.equals("VVV")){
namabarang1=" TELEVISI ";
harga1=6000000;}
else
if(kodebarang1.equals("RRR")){
namabarang1=" RADIO ";
harga1=500000;}
else
System.out.println("Kode yang Dimasukkan Salah! Ulangi Masukkan Kode Barang");
hargatotal1=harga1*jumlahbarang1;
System.out.print ("Masukkan Kode Barang: " );
kodebarang2 = ya.nextLine();
kodebarang2 = ya.nextLine();
System.out.print ("Masukkan Jumlah Barang: " );
jumlahbarang2 = ya.nextInt();
if(kodebarang2.equals("HHH")){
namabarang2=" HANDPHONE ";
harga2=2500000;}
else
if(kodebarang2.equals("LLL")){
namabarang2=" LAPTOP ";
harga2=7000000;}
else
if(kodebarang2.equals("TTT")){
namabarang2=" TABLET ";
harga2=4500000;}
else
if(kodebarang2.equals("VVV")){
namabarang2=" TELEVISI ";
harga2=6000000;}
else
if(kodebarang2.equals("RRR")){
namabarang2=" RADIO ";
harga2=500000;}
else
System.out.println("Kode yang Dimasukkan Salah! Ulangi Masukkan Kode Barang");
hargatotal2=harga2*jumlahbarang2;
System.out.print ("Masukkan Kode Barang: " );
kodebarang3 = ya.nextLine();
kodebarang3 = ya.nextLine();
System.out.print ("Masukkan Jumlah Barang: " );
jumlahbarang3 = ya.nextInt();
if(kodebarang3.equals("HHH")){
namabarang3=" HANDPHONE ";
harga3=2500000;}
else
if(kodebarang3.equals("LLL")){
namabarang3=" LAPTOP ";
harga3=7000000;}
else
if(kodebarang3.equals("TTT")){
namabarang3=" TABLET ";
harga3=4500000;}
else
if(kodebarang3.equals("VVV")){
namabarang3=" TELEVISI ";
harga3=6000000;}
else
if(kodebarang3.equals("RRR")){
namabarang3=" RADIO ";
harga3=500000;}
else
System.out.println("Kode yang Dimasukkan Salah! Ulangi Masukkan Kode Barang");

hargatotal3=harga3*jumlahbarang3;
System.out.print ("Masukkan Kode Barang: " );
kodebarang4 = ya.nextLine();
kodebarang4 = ya.nextLine();
System.out.print ("Masukkan Jumlah Barang: " );
jumlahbarang3 = ya.nextInt();
if(kodebarang4.equals("HHH")){
namabarang5=" HANDPHONE ";
harga2=2500000;}
else
if(kodebarang4.equals("LLL")){
namabarang5=" LAPTOP ";
harga2=7000000;}
else
if(kodebarang4.equals("TTT")){
namabarang5=" TABLET ";
harga2=4500000;}
else
if(kodebarang4.equals("VVV")){
namabarang5=" TELEVISI ";
harga2=6000000;}
else
if(kodebarang4.equals("RRR")){
namabarang5=" RADIO ";
harga2=500000;}
else
System.out.println("Kode yang Dimasukkan Salah! Ulangi Masukkan Kode Barang");
hargatotal4=harga2*jumlahbarang3;

System.out.println(" ");
System.out.println("=========================================================================================================");
System.out.println("                                           22 MINI MARKET                                              ");
System.out.println("                                Jalan YOU AND ME FOR US No.22 Semarang                                ");
System.out.println("=========================================================================================================");
System.out.println("                        DAFTAR TRANSAKSI ANDA                               ");
System.out.println(" ");
System.out.print("|  No.   |");System.out.print(("Kode Barang"));System.out.print(" | ");System.out.print(("Nama Barang"));System.out.print(" | ");System.out.print("Harga Satuan");System.out.print("  | ");System.out.print("Jumlah");System.out.print(" | ");System.out.print("Harga");System.out.println(" | ");
System.out.print("|   1    |");System.out.print((kodebarang1));System.out.print(" | ");System.out.print((namabarang1));System.out.print(" | ");System.out.print(harga1);System.out.print(" | ");System.out.print( jumlahbarang1 );System.out.print(" | ");System.out.print(       hargatotal1      );System.out.println(" | ");
System.out.print("|   2    |");System.out.print((kodebarang2));System.out.print(" | ");System.out.print((namabarang2));System.out.print(" | ");System.out.print(harga2);System.out.print(" | ");System.out.print(      jumlahbarang2    );System.out.print(" | ");System.out.print(       hargatotal2      );System.out.println(" | ");
System.out.print("|   3    |");System.out.print((kodebarang3));System.out.print(" | ");System.out.print((namabarang3));System.out.print(" | ");System.out.print(harga3);System.out.print(" | ");System.out.print(      jumlahbarang3    );System.out.print(" | ");System.out.print(       hargatotal3      );System.out.println(" | ");
System.out.print("|   4    |");System.out.print((kodebarang4));System.out.print(" | ");System.out.print((namabarang5));System.out.print(" | ");System.out.print(harga2);System.out.print(" | ");System.out.print(      jumlahbarang3    );System.out.print(" | ");System.out.print(       hargatotal3      );System.out.println(" | ");
System.out.println("                                 TERIMAKASIH BERBELANJA DI TOKO KAMI");
System.out.println("                                            SALAM HANGAT :)");
System.out.println("=========================================================================================================");
}

}


sekarang, run program dan lakukan inputan dan pada akirnyaaaa




temen-temen yang berwarna hijau itu merupakan inputan..
dan, tabel yang dihasilkan merupakan output..
sudah mengertikan sekarang??

silahkan mencoba ^^
TERIMAKASIH

Tidak ada komentar:

Posting Komentar