.: Java :. Banyaknya data Java

public class array_banyaknyaData {
public static void main(String[] args) throws IOException {
// TODO code application logic here
int i, n, data, harga = 50000;
BufferedReader x = new BufferedReader (new InputStreamReader(System.in));
System.out.print(“Banyaknya Data   : “);
n = Integer.parseInt(x.readLine());
String[] nama;
nama = new String[n];
int[] tiket, jumlah;
double[] total, diskon;
tiket  = new int[n];
jumlah  = new int[n];
total = new double[n];
diskon  = new double[n];
for (i=0; i<n; i++){
System.out.println(“\nData ke – “+(i+1));
System.out.print(“Nama Penumpang  : “);
nama[i]=x.readLine();
System.out.print(“Jumlah Pembelian : “);
jumlah[i]=Integer.parseInt(x.readLine());
}
for (i=0; i<n; i++){
System.out.println(“\n\nData ke – “+(i+1));
System.out.println(“Nama    : “+nama[i]);
System.out.println(“Harga Tiket   : “+harga);
System.out.println(“Jumlah Tiket  : “+jumlah[i]);
if (jumlah[i]>3){
diskon[i]=0.1*jumlah[i]*harga;
total[i]=(jumlah[i]*harga)-diskon[i];
}
else {
diskon[i]=0;
total[i]=(jumlah[i]*harga)-diskon[i];
}
System.out.println(“Total    : “+total[i]+”\n”);
}
}
}

Berikut hasil outputnya :array

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s