PROGRAM CARA MENGHITUNG DISKON mengunakan NetBeans

Contoh 

Diskon 10 %  jika beli antara 100 - 120 unit 
Diskon 30 %  jika lebih dari 120 unit
jika kurang dari 100 tidak ada diskon

Hitung hasil setelah diskon?

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package menghitung.program.diskon;

import java.util.Scanner;

/**
 *
 * @author ACER
 */
public class MenghitungProgramDiskon {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Harga Produk = ");

        int harga = sc.nextInt();
        System.out.println("Jumlah Beli = ");
        int qty =sc.nextInt();
        double diskon = 0;
        if (qty>120){
            diskon = 0.30;
            
    } else if (qty>100) {
        diskon = 0.1; 
    }
        int harga_awal = harga * qty;
       int harga_diskon = (int) (harga_awal - (harga_awal * diskon));
        System.out.println("Harga Awal = " + harga_awal);
        System.out.println("Diskon yang diberikan = " + (diskon*100));
        System.out.println(harga_awal * diskon);
        System.out.println("Harga Setelah Diskon =" + harga_diskon);
        
    }
}


Berikut hasil gambar :

Gambar diskon 10%

Gambar diskon 30%


Gambar tanpan diskon


















No comments:

Post a Comment