Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fungsi;
- import java.util.Scanner;
- public class Fungsi {
- public static void main(String[] args) {
- Scanner masukan = new Scanner(System.in);
- int pilihan=9;
- do{
- System.out.println("\nMENU\n");
- System.out.println("1. menghitung Gaji karyawan");
- System.out.println("2. Menghitung Berat badan karyawan");
- System.out.println("3. Menghitung Hutang karyawan");
- System.out.println("0. Keluar");
- System.out.println("Masukkan Pilihan Anda :");
- pilihan = masukan.nextInt();
- switch(pilihan){
- case 1 : gajikaryawan();break;
- case 2 : beratbadankaryawan();break;
- case 3 : hutangkaryawan();break;
- }
- }
- while(pilihan !=0);
- }
- private static void gajikaryawan() {
- String nama,barang;
- int gajipokok = 0;
- int totalgaji = 0;
- int tunjangan_istri_dan_anak = 0;
- int pajak = 0;
- Scanner masukan = new Scanner (System.in);
- System.out.print("\tProgram Perhitungan Gaji Kariawan");
- System.out.print("\n====================================================");
- System.out.print("\nMasukan Nama : "); nama = masukan.nextLine();
- System.out.print("\nMasukan NIK : ");
- int NIK = masukan.nextInt();
- System.out.println("1. golongan 1A");
- System.out.println("2. golongan 1B");
- System.out.println("3. golongan 2A");
- System.out.println("4. golongan 2B");
- System.out.println("5. golongan 3A");
- System.out.println("6. golongan 3B");
- System.out.print("");
- System.out.print("Masukan pilihan golongan : ");
- int pilih = masukan.nextInt();
- if (pilih==1)
- {
- gajipokok=1000000;
- tunjangan_istri_dan_anak=100000;
- }
- else if (pilih==2)
- {
- gajipokok=1500000;
- tunjangan_istri_dan_anak=200000;
- }
- else if (pilih==3)
- {
- gajipokok=2000000;
- tunjangan_istri_dan_anak=300000;
- }
- else if (pilih==4)
- {
- gajipokok=2500000;
- tunjangan_istri_dan_anak=400000;
- }
- else if (pilih==5)
- {
- gajipokok=3000000;
- tunjangan_istri_dan_anak=500000;
- }
- else if (pilih==6)
- {
- gajipokok=3500000;
- tunjangan_istri_dan_anak=600000;
- }
- pajak=((5/2)*(gajipokok+tunjangan_istri_dan_anak))/100;
- totalgaji=((gajipokok+tunjangan_istri_dan_anak)-pajak);
- System.out.print("====================================================");
- System.out.println("\nNama Karyawan = " + nama);
- System.out.println("NIK Karyawan = " + NIK);
- System.out.println("Gaji Pokok = " + gajipokok);
- System.out.println("Tunjangan Istri dan Anak = " + tunjangan_istri_dan_anak);
- System.out.println("Pajak = " + pajak);
- System.out.println("Total Gaji yang Diterima = " +totalgaji);
- System.out.print("====================================================");
- }
- private static void beratbadankaryawan() {
- System.out.println("\tProgram indeks masa tubuh karyawan ");
- System.out.println("====================================================");
- Scanner masukan = new Scanner(System.in);
- float tinggi, berat, hasil;
- System.out.print("Masukkan Tinggi Badan (m) = ");
- tinggi = masukan.nextFloat();
- System.out.print("Masukkan Berat Badan (kg) = ");
- berat = masukan.nextFloat();
- hasil = berat / (tinggi*tinggi);
- if (hasil <= 18.5f )
- System.out.println("Kurus");
- else if ((18.5f < hasil) && (hasil <= 25))
- System.out.println("Normal");
- else if ((25 < hasil) && (hasil <= 30))
- System.out.println("Gemuk");
- else
- System.out.println("Obesitas");
- }
- private static void hutangkaryawan() {
- Scanner masukan = new Scanner(System.in);
- System.out.println("Program Penghitung Angsuran Hutang karyawan");
- System.out.println("====================================================");
- int pinjaman, lamaAngsuran, bunga, angsuran, pembayaran;
- System.out.print("Masukkan besar pinjaman : ");
- pinjaman = masukan.nextInt();
- System.out.print("Masukkan lama angsuran (bulan) : ");
- lamaAngsuran = masukan.nextInt();
- System.out.print("Masukkan besar bunga (%) : ");
- bunga = masukan.nextInt();
- angsuran = pinjaman/lamaAngsuran;
- for(int i=0; i<lamaAngsuran; i++){
- pembayaran = angsuran + (pinjaman * bunga / 100);
- System.out.println("Pembayaran bulan ke-"+(i+1)+" = "+pembayaran);
- pinjaman = pinjaman - angsuran;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement