dan juga untuk tugas dari mata kuliah Lab Java, disini gwe menggunakan Scanner seperti yang telah gwe postingin beberapa waktu lalu.
Tapi untuk yang akan gwe muat kali ini agak panjang listingnya tapi semakin menarik untuk dipelajari karena disini ada tampilan awal, input proses dan hasil.
Ngak perlu banyak basa-basi lagi karena bila kebanyakan ngak enak tar basi jadinya, karena gwe juga masih awam dalam dunia java terlebih bahasa Pemrograman, nih listingnya :
/*---------------
| MARYADI |
| 12090609 |
----------------*/
import java.util.Scanner;
class tgs
{
public static void main(String [] args )
{
Scanner input = new Scanner(System.in);
int i, k;
int jumlah_byr = 0;
int pajak, total;
String[] kode;
String[] jenis;
int[] data_jual;
int[] banyak;
int [] harga;
System.out.println();
System.out.println(" GEROBAK FRIED CHICKEN");
System.out.println(" $$$$$ M4RRY $$$$$");
System.out.println("----------------------------");
System.out.println("Kode Jenis Harga ");
System.out.println("----------------------------");
System.out.println();
System.out.println(" D Dada Rp. 2500");
System.out.println(" P Paha Rp. 2000");
System.out.println(" S Sayap Rp. 1500");
System.out.println();
System.out.println("----------------------------");
System.out.println();
System.out.print("Banyak jenis= ");
i = input.nextInt();
System.out.println();
data_jual = new int[i];
banyak = new int[i];
harga = new int[i];
kode = new String[i];
jenis = new String[i];
for(k=0;k<i;k++)
{
System.out.println("Jenis Ke - " + (k+1) );
System.out.print("Jenis potong [D/P/S] : ");
kode[k]= input.next();
switch(kode[k])
{
case "D" :
jenis[k] = "Dada";
harga[k] = 2500 ;
break;
case "P" :
jenis[k] = "Paha";
harga[k] = 2000 ;
break;
case "S" :
jenis[k] = "Sayap";
harga[k] = 1500;
break;
default:
jenis[k] = "salah input";
harga[k] = 0;
break;
}
System.out.print("Banyak potong : ");
banyak[k] = input.nextInt();
data_jual[k]=banyak[k]*harga[k];
jumlah_byr = jumlah_byr + data_jual[k];
System.out.println();
}
pajak = jumlah_byr * 10/100;
total = jumlah_byr + pajak;
System.out.println();
System.out.println(" GEROBAK FRIED CHICKEN");
System.out.println(" $$$$$ M4RRY $$$$$");
System.out.println("---------------------------------------");
System.out.println("No Jenis Harga Banyak Jumlah ");
System.out.println(" Potong Satuan beli Harga");
System.out.println("---------------------------------------");
System.out.println();
for(k=0;k<i;k++)
{
System.out.print((k+1) + " ");
System.out.print(jenis[k]);
System.out.print("\t"+ harga [k]);
System.out.print("\t"+ banyak [k]);
System.out.print("\t"+ data_jual[k]);
System.out.println();
}
System.out.println();
System.out.println("---------------------------------------");
System.out.println();
System.out.println("\t\t"+"Jumlah Bayar :"+"\t" +jumlah_byr);
System.out.println("\t\t"+"Pajak 10% :"+"\t" +pajak);
System.out.println("\t\t"+"Total Bayar :"+"\t" +total);
}
}
| MARYADI |
| 12090609 |
----------------*/
import java.util.Scanner;
class tgs
{
public static void main(String [] args )
{
Scanner input = new Scanner(System.in);
int i, k;
int jumlah_byr = 0;
int pajak, total;
String[] kode;
String[] jenis;
int[] data_jual;
int[] banyak;
int [] harga;
System.out.println();
System.out.println(" GEROBAK FRIED CHICKEN");
System.out.println(" $$$$$ M4RRY $$$$$");
System.out.println("----------------------------");
System.out.println("Kode Jenis Harga ");
System.out.println("----------------------------");
System.out.println();
System.out.println(" D Dada Rp. 2500");
System.out.println(" P Paha Rp. 2000");
System.out.println(" S Sayap Rp. 1500");
System.out.println();
System.out.println("----------------------------");
System.out.println();
System.out.print("Banyak jenis= ");
i = input.nextInt();
System.out.println();
data_jual = new int[i];
banyak = new int[i];
harga = new int[i];
kode = new String[i];
jenis = new String[i];
for(k=0;k<i;k++)
{
System.out.println("Jenis Ke - " + (k+1) );
System.out.print("Jenis potong [D/P/S] : ");
kode[k]= input.next();
switch(kode[k])
{
case "D" :
jenis[k] = "Dada";
harga[k] = 2500 ;
break;
case "P" :
jenis[k] = "Paha";
harga[k] = 2000 ;
break;
case "S" :
jenis[k] = "Sayap";
harga[k] = 1500;
break;
default:
jenis[k] = "salah input";
harga[k] = 0;
break;
}
System.out.print("Banyak potong : ");
banyak[k] = input.nextInt();
data_jual[k]=banyak[k]*harga[k];
jumlah_byr = jumlah_byr + data_jual[k];
System.out.println();
}
pajak = jumlah_byr * 10/100;
total = jumlah_byr + pajak;
System.out.println();
System.out.println(" GEROBAK FRIED CHICKEN");
System.out.println(" $$$$$ M4RRY $$$$$");
System.out.println("---------------------------------------");
System.out.println("No Jenis Harga Banyak Jumlah ");
System.out.println(" Potong Satuan beli Harga");
System.out.println("---------------------------------------");
System.out.println();
for(k=0;k<i;k++)
{
System.out.print((k+1) + " ");
System.out.print(jenis[k]);
System.out.print("\t"+ harga [k]);
System.out.print("\t"+ banyak [k]);
System.out.print("\t"+ data_jual[k]);
System.out.println();
}
System.out.println();
System.out.println("---------------------------------------");
System.out.println();
System.out.println("\t\t"+"Jumlah Bayar :"+"\t" +jumlah_byr);
System.out.println("\t\t"+"Pajak 10% :"+"\t" +pajak);
System.out.println("\t\t"+"Total Bayar :"+"\t" +total);
}
}
Dan hasil tampilanya seperti ini nih :
Nah itu hasilnya,,,, selamat mencoba ye,,,,,,,,,,