speecash

bisnis online, jual beli online, sistem pembayaran, pembayaran online, bisnis online

laman

Selasa, 06 Desember 2011

Prak Algo Modul 1 (java)



2.    Disebuah rental computer menerima jasa print dengan tariff print HP = Rp.500,-/lbr, Print BW Rp. 1000,-/lbr danjika dalam rental tersebut memberikan discount 10% untuk print per 10lbr. Maka berapakah total biaya yang akan kita bayar setiap kita melakukan print di rental tersebut ? buat flowchart dan program dengan inputan keyboard !
OPI
Output :  total biaya harga print
               Dengan ketentuan :
               Hp (Hitam putih) = Rp.500,-/lbr
               Bwn (Berwarna)  = Rp.1000,-/lbr
               Discount 10% untuk print per 10 lembar untuk masing masing jenis print
Proses :   -menentukan harga diskon untuk setiap jenis print
1.      Harga diskon print Hp (10 x 500) x 90% = 4500
2.      Harga diskon print Bwn (10 x 1000) x 90 % = 9000
-menentukan banyaknya print yang mendapat diskon
1. sisa print Hp = N print Hp % 10 
2. jumlah diskon print Hp = (N print Hp – sisa print Hp) /10
Untuk berwarna.
1.      Sisa print Bwn = N print Bwn  % 10
2.      Jumlah diskon print Bwn = (N print Bwn – sisa print Bwn)/10.
-menentukan harga yang harus dibayar
1.      print Hp :
         Total diskon Hp = jumlah diskon x harga diskon
         Harga sisa print Hp = sisa print Hp x harga per lembar
         Total harga Hp = Total diskon Hp + Harga sisa print Hp
2              print Bwn :
Total diskon Bwn = jumlah diskon x harga diskon
Harga sisa print Bwn = sisa print Hp x harga per lembar
Total harga Bwn = Total diskon Bwn x Harga sisa print Bwn
               -harga yang harus dibayar :
               Total harga = Total harga Hp + Total harga Bwn
Input :    N hp
               N Bwn
 
Flowchart

Analisa
Input :       print Hp = 24
                    Print Bwn = 15
Proses :    Harga diskon print Hp (10 x 500) x 90% = 4500
Harga diskon print Bwn (10 x 1000) x 90 % = 9000
               Sisa print Hp =  print Hp  % 10
               4 = 24%10
               Jumlah diskon print Hp = (N print Hp – sisa print Hp)/10
               Jumlah diskon print = (24 – 4) / 10
               2 = 20 / 10
               Sisa print Bwn = N print Bwn  % 10
               5 = 15 % 10
               Jumlah diskon print Bwn = (N print Bwn – sisa print Bwn)/10
               Jumlah diskon print Bwn = ( 15 – 5) / 10
               1 = 10 / 10
print Hp :
         Total diskon Hp = jumlah diskon x harga diskon
         9000 = 2 x 4500
         Harga sisa print Hp = sisa print Hp x harga per lembar
         2000 = 4 x 500
         Total harga Hp = Total diskon Hp + Harga sisa print Hp
         11000 = 9000 + 2000
               print Bwn :
Total diskon Bwn = jumlah diskon x harga diskon
9000 = 1 x 9000
Harga sisa print Bwn = sisa print Hp x harga per lembar
5000 = 5 x 5000
Total harga Bwn = Total diskon Bwn x Harga sisa print Bwn
14000 = 9000 + 5000
               Total harga = Total harga Hp + Total harga Bwn
               25000 = 11000 + 14000
Source code
import java.io.*;
class soal3
{
                    public static void main(String[] args)throws Exception
                    {                        
                                DataInputStream input = new DataInputStream(System.in);
                                System.out.print("masukkan jumlah print hitam putih = ");
                                String shp = input.readLine();
                                System.out.print("masukkan jumlah print berwarna = ");
                                String sbwn = input.readLine();
                                int hp = Integer.parseInt(shp);
                                int bwn = Integer.parseInt(sbwn);
                               
                                long harga_per_hp = 500;
                                long harga_per_bwn = 1000;
                               
                                long harga_diskon_hp = (harga_per_hp*10) - (harga_per_hp*10*10/100);
                                int jumlah_diskon_hp = hp/10;
                                int sisa_hp = hp%10;
long total_hp = (jumlah_diskon_hp*harga_diskon_hp) + (sisa_hp*harga_per_hp);
                               
                                long harga_diskon_bwn = (harga_per_bwn*10) - (harga_per_bwn*10*10/100);
                                int jumlah_diskon_bwn = bwn/10;
                                int sisa_bwn = bwn%10;
long total_bwn = (jumlah_diskon_bwn*harga_diskon_bwn) + (sisa_bwn*harga_per_bwn);
                                               
                                long total_pembayaran = total_hp + total_bwn;
                               
                                System.out.println("total harga print hitam putih = "+total_hp);
                                System.out.println("total harga print berwarna    = "+total_bwn);
                                System.out.println("---------------------------------------- +");
                                System.out.println("total harga pembayaran        = "+total_pembayaran);
                    }
}

Tidak ada komentar:

Posting Komentar