Contoh program Java ( Diskon)

26 02 2011

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package progif;

/**

*

* @Helmi@10108936@3KA04

*/

public class Main {

double Diskon;

int Qty;

double Jumlah;

float Harga;

double Bayar;

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Main mv=new Main();

mv.Diskon=0;

mv.Qty=3;

mv.Harga=300000;

mv.Jumlah=mv.Qty*mv.Harga;

if (mv.Jumlah>=100000)

{

mv.Diskon=mv.Jumlah*0.1;

}

mv.Bayar=mv.Jumlah-mv.Diskon;

System.out.println(“\nBayar=”+mv.Bayar);

}

}

Maksud dari program di atas adalah: Jika variabel atau data Jumlah lebih besar atau

sama dengan 100000, maka data Diskon dihitung dari Jumlah dikali

0.1 (10%). Data Bayar didapat dari Data Jumlah dikurang data

Diskon.


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: