Rabu, 26 Oktober 2016

Tugas UTS Mata kuliah Algoritma

1. Penjelasan Kasus Program

Sebuah super market mengadakan diskon besar besaran untuk semua item barang ,
Chitato  = 10500
Kacang garuda  = 15000
Pure life = 3000
Qtela = 4500
biskuit  = 10000

Jika seluruh   barang mencapai harga total 30000 konsumen mendapatkan diskon  5%   jika tidak konsumen  tidak mendapatkan 0%

2. Flowchart


3. Source Coding
/*
 * 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 pkgif;

/**
 *
 * @author Pemakai
 */
public class If {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
   int hargatotal,chitato,kacanggaruda,purelife,qtela,biskuit,diskon;
   chitato = 10500;
   kacanggaruda = 15000;
   purelife = 3000;
   qtela = 4000;
   biskuit = 10000;
   
   hargatotal= chitato+kacanggaruda+purelife+qtela+biskuit;
    System.out.println(" harga total = " + hargatotal);
    
   if (hargatotal>=30000) {

diskon=hargatotal*5/100;

hargatotal= hargatotal - diskon;

System.out.println("diskon = 5%\n"+hargatotal); }

}

}


Jumat, 14 Oktober 2016

Studi Kasus

Sebuah toko swalayan  mengadakan diskon besar-besaran.

Ditentukan :

Biscuit khongguan = 90000
Teh pucuk               = 5000
Jika total belanja > 75000 Mendapat diskon 25%.

Selain itu diskon 0%.

Flowchart


source code

/*
 * 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.
 */

/**
 *
 * @author Dian Parirani
 */
public class ifdiskon {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    int totalbelanja,khonguan,tehpucuk,diskon;
    khonguan=90000;
    tehpucuk=5000;
    totalbelanja=khonguan+tehpucuk;
    System.out.println(""+totalbelanja);
   
    if(totalbelanja>=75000){
            diskon=totalbelanja*20/100;
            totalbelanja=totalbelanja-diskon;
            System.out.println("diskon=20%\n"+totalbelanja);
           
        }
   
   
   
   
   
    }
   
}