Latihan Array 3 - JAVA

import javax.swing.JOptionPane;

public class Latihan_Array_3
{
    public static void main(String[] args)
    { 
   
    String[] nama = new String[20];
    String[] merk = new String[20];
    String[] tipe = new String[20];
    int[] jmlbeli = new int[20];
    double[] harga = new double[20];
    double[] total = new double  [20];
    String jawab="";
    int i=0;   
    int j=0;

    System.out.println("");
    System.out.println("              Helm Yang Tersedia                ");
    System.out.println("____________________________________________________");
    System.out.println("            *---- MERK HELM ----*  ");
    System.out.println("                  1.Ink");
    System.out.println("                  2.Kyt");
    System.out.println("                  3.Arai");
    System.out.println("                  4.Bmc");
    System.out.println("                  5.Kbc");
    System.out.println("                  6.Nollan");
    System.out.println("                  7.Agp");
    System.out.println("                  8.Wtc");
    System.out.println("");
    System.out.println("            *---- TIPE HELM ----*  ");
    System.out.println("                  1.Ink Dc");
    System.out.println("                  2.Kyt Troy");
    System.out.println("                  3.Arai 7x");
    System.out.println("                  4.Bmc Full");
    System.out.println("                  5.Kbc Race");
    System.out.println("                  6.Nollan Race");
    System.out.println("                  7.Agp Race");  
    System.out.println("                  8.Wtc Gold");
    System.out.println("____________________________________________________");
  
  

    do
    {
    nama[i]=JOptionPane.showInputDialog("Nama Pembeli  = ");
    merk[i]=JOptionPane.showInputDialog("Merk Helm  = ");
    tipe[i]=JOptionPane.showInputDialog("Tipe Helm  = ");
    jmlbeli[i]=Integer.valueOf(JOptionPane.showInputDialog("Jumlah Helm yang Dibeli  = "));
  
  
    if (merk[i].equals("Ink") && tipe[i].equals("Ink Dc"))
        harga[i]=150000;
        else
    if (merk[i].equals("Kyt") && tipe[i].equals("Kyt Troy"))
        harga[i]=200000;
        else
    if (merk[i].equals("Arai") && tipe[i].equals("Arai 7x"))
        harga[i]=450000;
        else
    if (merk[i].equals("Bmc") && tipe[i].equals("Bmc Full"))
        harga[i]=100000;
        else
    if (merk[i].equals("Kbc") && tipe[i].equals("Kbc Race"))
         harga[i]=250000;
         else
     if (merk[i].equals("Nollan") && tipe[i].equals("Nollan Race"))
        harga[i]=500000;
        else
    if (merk[i].equals("Agp") && tipe[i].equals("Agp Race"))
        harga[i]=350000;
        else
    if (merk[i].equals("Wtc") && tipe[i].equals("Wtc Gold"))
        harga[i]=120000;
    else
        harga[i]=0;

    total[i]=harga[i]*jmlbeli[i];
   
    i++;
    jawab=JOptionPane.showInputDialog("Mau Tambah data lagi Y/T");
    }
    while(jawab.equalsIgnoreCase("Y"));
    System.out.println("Nama\tMerk Helm\tTipe Helm\tJumlah Beli\tHarga\t\tTotal");
    System.out.println("==================================================================================");
    System.out.println(""+nama[j]+"\t"+merk[j]+"\t\t"+tipe[j]+"\t"+jmlbeli[j]+"\t\t"+harga[j]+"\t"+total[j]);
    System.out.println("==================================================================================");
    }
}

NEXT

No comments:

Post a Comment