0% found this document useful (0 votes)
7 views

Java Class

The Java program 'TokoBaju' calculates discounts for clothing purchases based on the total amount spent and whether the customer has a credit card. Discounts are applied at different rates depending on the purchase amount, with additional discounts for credit card payments. The program outputs the total amount to be paid after applying the applicable discounts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Java Class

The Java program 'TokoBaju' calculates discounts for clothing purchases based on the total amount spent and whether the customer has a credit card. Discounts are applied at different rates depending on the purchase amount, with additional discounts for credit card payments. The program outputs the total amount to be paid after applying the applicable discounts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

import java.util.

Scanner;

public class TokoBaju {

public static void main(String[] args) {

// deklarasi variabel dan Scanner

int belanjaan,diskon,bayar;

int diskonn;

String kartu;

Scanner scan = new Scanner(System.in);

// mengambil input

System.out.println
("########################################################");

System.out.println ("Nama:SITI ALUS NINGSIH");

System.out.println ("Nim:0701171014");

System.out.println ("Kelas:IK-2");

System.out.println ("Mata Kuliah : PBO");

System.out.println
("########################################################");

System.out.println("Jika Belanja lebih dari 500 ribu mendapat potongan 10% ");

System.out.println("Jika Belanja lebih dari 1 juta mendapat potongan 12%");

System.out.println("Jika Belanja lebih dari 2 juta mendapat potongan 20%");

System.out.println("Jika Pelanggan Membayar dengan kartu kredit mendapat diskon


tambahan 10%");

System.out.println("-------------------------------------------------------------------------");

System.out.println("Apakah anda mempunyai kartu kredit ?");

kartu = scan.nextLine();

System.out.print("Total belanjaan Awal : ");

belanjaan = scan.nextInt();

// proses
if (kartu.equalsIgnoreCase("ya")) {

if (belanjaan > 2000000) {

diskonn=(belanjaan*20/100);

diskon=(belanjaan*30)/100;

System.out.println("Diskon Awal= 20%\n" +diskonn);

System.out.println("Diskon Tambahan= 30%\n" +diskon);

} else if (belanjaan > 1000000) {

diskonn=(belanjaan*12)/100;

diskon =(belanjaan*22)/100;

System.out.println("Diskon Awal= 12%\n" +diskonn);

System.out.println("Diskon Tambahan= 22%\n" +diskon);

} else if (belanjaan > 500000){

diskonn=(belanjaan*10)/100;

diskon =(belanjaan*20)/100;

System.out.println("Diskon Awal= 10%\n" +diskonn);

System.out.println("Diskon Tambahan= 20%\n" +diskon);

}else{

diskon=0;

} else {

if (belanjaan > 2000000) {

diskon =(belanjaan*20)/100;

System.out.println("Total Diskon= 20%\n" +diskon);


} else if (belanjaan > 1000000) {

diskon =(belanjaan*12)/100;

System.out.println("Total Diskon= 12%\n" +diskon);

} else if (belanjaan > 500000){

diskon =(belanjaan*10)/100;

System.out.println("Total Diskon= 10%\n" +diskon);

} else {

diskon = 0;

// total yang harus dibayar

// output

bayar = belanjaan - diskon;

System.out.println("Total Bayar: Rp " + bayar);

You might also like