Selasa, 25 Oktober 2011

Tugas Lat3 PEMROGRAMAN BERBASIS OBJECT




/*
 * Created on Oct 24, 2011
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */


/**
 * @author User
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

import java.io.*;


public class tokoSusu
{
    public tokoSusu()
    {
        awal();
    }
  
    public void awal()
    {
        System.out.println("TOKO KELONTONG KERONCONGAN");
        System.out.println("--------------------------");
        System.out.println("A. Susu Dancow");
        System.out.println("\t1.Ukuran Kecil");
        System.out.println("\t2.Ukuran Sedang");
        System.out.println("\t3.Ukuran Besar");
      
        System.out.println("B. Susu Bendera");
        System.out.println("\t1.Ukuran Kecil");
        System.out.println("\t2.Ukuran Sedang");
        System.out.println("\t3.Ukuran Besar");
      
        System.out.println("C. Susu SGM");
        System.out.println("\t1.Ukuran Kecil");
        System.out.println("\t2.Ukuran Sedang");
        System.out.println("\t3.Ukuran Besar");
    }
  
    public static void main(String[] args)
    {
      
        tokoSusu tSusu = new tokoSusu();
        System.out.print("Masukkan Merk Susu [Dancow | Bendera | SGM]: ");
        try
        {
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader bf = new BufferedReader(isr);
            String merk = bf.readLine();
            System.out.print("\nMasukkan Ukuran Kaleng [Kecil|Sedang|Besar]: ");
            String ukuran = bf.readLine();
            double harga = 0;
            if(merk.toUpperCase().equals("DANCOW"))
            {
                if(ukuran.toUpperCase().equals("KECIL"))
                {
                    harga = 25000;
                }
                else if(ukuran.toUpperCase().equals("SEDANG"))
                {
                    harga = 20000;
                }
                else if(ukuran.toUpperCase().equals("BESAR"))
                {
                    harga = 15000;
                }
            }
            else if(merk.toUpperCase().equals("BENDERA"))
            {
                if(ukuran.toUpperCase().equals("KECIL"))
                {
                    harga = 20000;
                }
                else if(ukuran.toUpperCase().equals("SEDANG"))
                {
                    harga = 17500;
                }
                else if(ukuran.toUpperCase().equals("BESAR"))
                {
                    harga = 13500;
                }
            }
            else if(merk.toUpperCase().equals("SGM"))
            {
                if(ukuran.toUpperCase().equals("KECIL"))
                {
                    harga = 22000;
                }
                else if(ukuran.toUpperCase().equals("SEDANG"))
                {
                    harga = 18500;
                }
                else if(ukuran.toUpperCase().equals("BESAR"))
                {
                    harga = 15000;
                }
            }
          
            System.out.print("\nJumlah Yang Dibeli: ");
            int jml = Integer.parseInt(bf.readLine());
            System.out.print("\nHarga Yang Harus Dibayar Sebesar Rp. "+ jml * harga);
        }
        catch(Exception ex)
        {
            System.out.println(ex.getMessage());
        }
      
    }
}

Tidak ada komentar:

Posting Komentar