RSS

Sourece PBO Praktikum Bagian 2

/* Source code kondisional if */

import java.util.Scanner;

public class Prak_201 {

    public static void main(String[] args) {
    Scanner masukan = new Scanner (System.in);
    int nilai;
    System.out.print("Masukan Nilai Akhir Mata Kuliahnya : ");
    nilai = masukan.nextInt();
    if (nilai < 55)

    System.out.println("Mahasisawa Tersebut Tidak Lulus");
    }
}


/* Source code kondisional if else */

import java.util.Scanner;

public class Prak_202 {

    public static void main(String[] args) {
    Scanner masukan = new Scanner (System.in);
    int nilai;
    System.out.print("Masukan Nilai Akhir Mata Kuliahnya : ");
    nilai = masukan.nextInt();
    if (nilai < 55)
    System.out.println("Mahasisawa Tersebut Tidak Lulus");
    else
    System.out.println("Mahasisawa Tersebut Lulus");   
    }
}

/* Source code kondisional if else if  */

import java.util.Scanner;

public class Prak_203 {

    public static void main(String[] args) {
    Scanner masukan = new Scanner (System.in);
    System.out.print("Masukan nilai matakuliahnya = ");
    int nilai = masukan.nextInt();
    if (nilai >= 80)
    System.out.println("NIlainya A");
    else if (nilai >= 70)
    System.out.println("Nilainya B");
    else if (nilai >=55)
    System.out.println("Nilainya C");
    else if (nilai >= 40)
    System.out.println("Nilainya D");
    else
    System.out.println("Nilainya E");
    }
}

/* Source code kondisional switch */

import java.util.Scanner;

public class Prak_204 {

    public static void main(String[] args) {
    Scanner masukan = new Scanner(System.in);
    System.out.print("Bulan ke - :");
    int bil = masukan.nextInt();
    switch (bil) {
    case 1: System.out.println("Januari"); break;
    case 2: System.out.println("Februari"); break;
    case 3: System.out.println("Maret"); break;
    case 4: System.out.println("April"); break;
    case 5: System.out.println("Mei"); break;
    case 6: System.out.println("Juni"); break;
    case 7: System.out.println("Juli"); break;
    case 8: System.out.println("Agustus"); break;
    case 9: System.out.println("September"); break;
    case 10: System.out.println("Oktober"); break;
    case 11: System.out.println("November"); break;
    case 12: System.out.println("Desember"); break;
        }
    }
}

/* Source code kondisional switch dan default */

import java.util.Scanner;

public class Prak_205 {
   
    public static void main(String[] args) {
    Scanner masukan = new Scanner(System.in);
    System.out.print("Bulan ke - :");
    int bil = masukan.nextInt();
    switch (bil) {
    case 1: System.out.println("Januari"); break;
    case 2: System.out.println("Februari"); break;
    case 3: System.out.println("Maret"); break;
    case 4: System.out.println("April"); break;
    case 5: System.out.println("Mei"); break;
    case 6: System.out.println("Juni"); break;
    case 7: System.out.println("Juli"); break;
    case 8: System.out.println("Agustus"); break;
    case 9: System.out.println("September"); break;
    case 10: System.out.println("Oktober"); break;
    case 11: System.out.println("November"); break;
    case 12: System.out.println("Desember"); break;
    default: System.out.println("Angka yang ditulis diluar range");
        }
    }
}

/* Source code menentukan nilai */

import java.util.Scanner;

public class Prak_206 {

    public static void main(String[] args) {
    Scanner masukan = new Scanner (System.in);
    System.out.print("Masukan nilai Matematikanya : ");
    int matematika = masukan.nextInt();
    System.out.print("Masukan nilai Fisikanya : ");
    int fisika = masukan.nextInt();
    if ((matematika > 80) && (fisika > 70))
    System.out.println("Siswa tersebut diterima");
    else
    System.out.println("Siswa tersebut tidak diterima");
    }
}


/* Source code menentukan gaji karyawan sesuai jam kerja per-minggu */

import java.util.Scanner;

public class Soal_302 {

    public static void main(String[] args) {
        Scanner masukan = new Scanner (System.in);
        int jam;
        double gaji,totalgaji,plus,minus,sisa;
        System.out.print("Masukan Total Jam Kerja Anda/Minggu : ");
        jam = masukan.nextInt();
        if (jam>=60){
            sisa = jam - 60;
            jam = (int) (jam - sisa);
            gaji = jam*5000;
            plus = sisa*7500;
            totalgaji = gaji+plus;
        System.out.println("Maka Gaji Karyawan = Rp.7500/Jam & Total Gajinya/minggu = "+totalgaji);}
        else if (jam<50) {
            sisa = 50 - jam;
            gaji = jam*5000;
            minus = sisa*2500;
            totalgaji = gaji-minus;
        System.out.println("Maka Gaji Karyawan = Rp.2500/Jam & Total Gajinya/minggu = "+totalgaji);}
        else {
            totalgaji = jam*5000;
        System.out.println("Maka Gaji Karyawan = Rp.5000/Jam & Total Gajinya/minggu = "+totalgaji);}
       
        System.out.println("*** Tian Chan ***");
    }
}

/* Source code mencari letak kuadran */

import java.util.Scanner;

public class Soal_303 {

    public static void main(String[] args) {
        Scanner input = new Scanner (System.in);
        int X, Y, Kuadran = 0;
        System.out.println("MENCARI LETAK KUADRAN DARI TITIK P(X,Y)");
        System.out.print("Mencari Titik X : ");
        X = input.nextInt();
        System.out.print("Mencari Titik Y : ");
        Y = input.nextInt();
        System.out.println("Letak P(X) : "+X);
        System.out.println("Letak P(Y) : "+Y);
        if (X>0&&Y>0){
        Kuadran = (int) (1);}
        else if (X<0&&Y>0){
        Kuadran = (int) (2);}
        else if (X<0&&Y<0){
        Kuadran = (int) (3);}
        else if (X>0&&Y<0){
        Kuadran = (int) (4);}
        System.out.println();        
        System.out.println("Letak Titik P nya adalah = "+Kuadran);
        System.out.println();
        System.out.println("*** Tian Chan ***");
    }
}

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment