Rabu, 28 Maret 2012
Algoritma Pemrograman : Gaji Karyawan (Method)
Soal :
Contoh Program Java :
//////////////////////////////////////////////////////////////////////////////
import java.util.Scanner;
public class Prak02_11520241015{
static int gol=0,gaji=0,jamker=0,gajijam=0,jam_lembur=0,gajilembur=0,total=0;
static String nama;
//sub rutin (method) procedure
public static void main(String []args){
System.out.println(" === ENTRY DATA === ");
System.out.print("Masukkan nama karyawan : ");
Scanner c =new Scanner (System.in);
nama =c.nextLine();
System.out.print("Masukkan golongan karyawan : ");
Scanner a =new Scanner (System.in);
gol =a.nextInt();
System.out.print("Masukkan jumlah jam kerja : ");
Scanner b =new Scanner (System.in);
jamker =b.nextInt();
//menghitung golongan, gaji tetap, gaji per jam
if(gol == 1){
gaji= 500000; gajijam = 50000;
}
else if (gol== 2){
gaji = 300000; gajijam = 3000;
}
else if (gol == 3){
gaji= 250000; gajijam = 2000;
}
else if (gol == 4){
gaji = 100000; gajijam = 1500;
}
else if(gol == 5){
gaji = 50000; gajijam = 1000;
}
//menghitung jumlah jam lembur & gaji lembur
if (jamker>150){
jam_lembur= jamker - 150;
gajilembur = (int) (jam_lembur*1.5*gajijam);
}
//menghitung total gaji
total=gaji+gajilembur;
// print data karyawan
System.out.println("\n\n === DATA KARYAWAN === " );
System.out.println("Nama karyawan : " +nama);
System.out.println("Golongan karyawan : " +gol);
System.out.println("Gaji tetap : " +gaji);
System.out.println("Gaji per jam : " +gajijam);
System.out.println("Jumlah jam kerja : " +jamker);
System.out.println("Jumlah jam lembur : " +jam_lembur);
System.out.println("Jumlah gaji lembur : " +gajilembur);
System.out.println("Gaji total : " +total);
}
// sub rutin (method) function
public int jam_lembur() {
return jam_lembur;
}
// sub rutin (method) function
public int gajilembur() {
return gajilembur;
}
// sub rutin (method) function
public int total() {
return total;
}
}
Output :
Contoh Program Java :
//////////////////////////////////////////////////////////////////////////////
import java.util.Scanner;
public class Prak02_11520241015{
static int gol=0,gaji=0,jamker=0,gajijam=0,jam_lembur=0,gajilembur=0,total=0;
static String nama;
//sub rutin (method) procedure
public static void main(String []args){
System.out.println(" === ENTRY DATA === ");
System.out.print("Masukkan nama karyawan : ");
Scanner c =new Scanner (System.in);
nama =c.nextLine();
System.out.print("Masukkan golongan karyawan : ");
Scanner a =new Scanner (System.in);
gol =a.nextInt();
System.out.print("Masukkan jumlah jam kerja : ");
Scanner b =new Scanner (System.in);
jamker =b.nextInt();
//menghitung golongan, gaji tetap, gaji per jam
if(gol == 1){
gaji= 500000; gajijam = 50000;
}
else if (gol== 2){
gaji = 300000; gajijam = 3000;
}
else if (gol == 3){
gaji= 250000; gajijam = 2000;
}
else if (gol == 4){
gaji = 100000; gajijam = 1500;
}
else if(gol == 5){
gaji = 50000; gajijam = 1000;
}
//menghitung jumlah jam lembur & gaji lembur
if (jamker>150){
jam_lembur= jamker - 150;
gajilembur = (int) (jam_lembur*1.5*gajijam);
}
//menghitung total gaji
total=gaji+gajilembur;
// print data karyawan
System.out.println("\n\n === DATA KARYAWAN === " );
System.out.println("Nama karyawan : " +nama);
System.out.println("Golongan karyawan : " +gol);
System.out.println("Gaji tetap : " +gaji);
System.out.println("Gaji per jam : " +gajijam);
System.out.println("Jumlah jam kerja : " +jamker);
System.out.println("Jumlah jam lembur : " +jam_lembur);
System.out.println("Jumlah gaji lembur : " +gajilembur);
System.out.println("Gaji total : " +total);
}
// sub rutin (method) function
public int jam_lembur() {
return jam_lembur;
}
// sub rutin (method) function
public int gajilembur() {
return gajilembur;
}
// sub rutin (method) function
public int total() {
return total;
}
}
Output :
Label:
algoritma,
gaji karyawan,
java,
kuliah,
pemrograman,
program java,
PTI 2012,
sem 2,
uny
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar