Script Java - Nested iF

/**
 * @(#)tugas3.java
 *
 *
 * @author
 * @version 1.00 2011/10/19
 */

import java.util.*;
public class tugas3
{
    public static void main (String[]args)
    {
            String kode,ukrn,merk,ukuran;
            long  satuan,jumbel,total;
           
            Scanner input=new Scanner(System.in);
           
            System.out.println("TOKO KELONTONG KERONCONGAN");
            System.out.println("--------------------------");
            System.out.println("A. Susu Dancow");
            System.out.println("   1. Ukuran Kecil");
            System.out.println("   2. Ukuran Sedang");
            System.out.println("   3. Ukuran Besar");
            System.out.println("B. Susu Bendera");
            System.out.println("   1. Ukuran Kecil");
            System.out.println("   2. Ukuran Sedang");
            System.out.println("   3. Ukuran Besar");
            System.out.println("C. Susu SGM");
            System.out.println("   1. Ukuran Kecil");
            System.out.println("   2. Ukuran Sedang");
            System.out.println("   3. Ukuran Besar");
           
            System.out.print("Masukkan Merk Susu [Dancow|Bendera|SGM]               : ");
                        kode=input.nextLine();
            System.out.print("Masukkan Ukuran Kaleng [Kecil|Sedang|Besar]              : ");
                        ukrn=input.nextLine();
                       
                        if(kode=="A" || kode=="a")
                        {
                                    merk="Dancow";
                                    if(ukrn=="1")
                                    {
                                                ukuran="Kecil";
                                                satuan=15000;
                                    }
                                    else if(ukrn=="2")
                                    {
                                                ukuran="Sedang";
                                                satuan=20000;
                                    }
                                    else
                                    {
                                                ukuran="Besar";
                                                satuan=25000;
                                    }
                        }
                        else if(kode=="B" || kode=="b")
                        {
                                    merk="Bendera";
                                    if(ukrn=="1")
                                    {
                                                ukuran="Kecil";
                                                satuan=13500;
                                    }
                                    else if(ukrn=="2")
                                    {
                                                ukuran="Sedang";
                                                satuan=17500;
                                    }
                                    else
                                    {
                                                ukuran="Besar";
                                                satuan=20000;
                                    }
                        }
                        else
                        {
                                    merk="SGM";
                                    if(ukrn=="1")
                                    {
                                                ukuran="Kecil";
                                                satuan=15000;
                                    }
                                    else if(ukrn=="2")
                                    {
                                                ukuran="Sedang";
                                                satuan=18500;
                                    }
                                    else
                                    {
                                                ukuran="Besar";
                                                satuan=22000;
                                    }
                        }
           
            System.out.println("Harga Satuan Rp. "+(long)satuan);
            System.out.print("Jumlah Yang Dibeli                                                                                              : ");
                        jumbel=input.nextLong();
           
            total=satuan*jumbel;
            System.out.println("Harga Yang Harus Dibayar                                                                    : "+total);
    }
}

Tidak ada komentar:

Posting Komentar