Anda di halaman 1dari 8

LAPORAN

Pemograman Lanjutan

Oleh
Andy saputra (6304201317)

PROGRAM STUDI D–IV REKAYASA PERANGKAT LUNAK


JURUSAN TEKNIK INFORMATIKA
POLITEKNIK NEGERI BENGKALIS
2021
1. Percobaan 1
import java.util.Scanner;

/*
* 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 Andy
*/
public class simpleIf {
public static void main (String[]args){
Scanner input =new Scanner (System.in);
System.out.println("Nilai :");
int nilai = input.nextInt();

if (nilai > 85){


System.out.println("Nilai anda bagus !");
}
else if (nilai >70){
System.out.println("nilai anda lumayan !");
}
else {
System.out.println("nilai anda kurang !!!");
}
}
}
screenShot

2. Percobaan 2
import java.util.Scanner;

/*
* 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 Andy
*/
public class simpleSwitch {
public static void main (String [] args){
Scanner masuk = new Scanner (System.in);

int pil;
System.out.println("Masukan Angka 1-3 pilihan jurusan : ");
pil= masuk.nextInt();
switch(pil){
case 1 :
System.out.println("Manajemen Informatika");
break;
case 2 :
System.out.println("Teknik Informatika");
break;
case 3 :
System.out.println("Komputerisasi akuntansi");
break;
case 4 :
System.out.println("Teknik Komputer");
break;
case 5 :
System.out.println("Sistem Informasi");
break;
default :
System.out.println("Pilihan salah !!!");
}
}
}
screenshot
3. Percobaan 3
public class simpleSwicth2 {
public static void main (String[]args){
System.out.println("Aplikasi Belanja");
System.out.println("================");
System.out.println("Silakan Pilih");
System.out.println("1. Member");
System.out.println("2. NON Member");
System.out.println("3. Keluar");
System.out.println();

int pilih = Integer.parseInt(JoptionPane.snowInputDialog("1. Member 2.NON Member


3. Keluar. masukan pilihan 1-3 "));
switch (pilih){
case 1:
int belanja = Integer.parseInt(JoptionPane.snowInputDialog("Masukan Nominal
Belanja"));

double diskon = 0.4 * belanja;

System.out.println("Total Belanja Anda = "+(belanja - diskon));


break;

case 2 :
int belanja1 = Integer.parseInt(JoptionPane.showInputDialog("Masukan Nominal
Belanja"));

double diskon1 =0.2 * belanja1;

System.out.println("Total Belanja Anda = "+ (belanja1 - diskon1));


break;
}
System.out.println("Terima Kasih ! Selamat Datang Kembali");
}
}

SCREENSHOT

1. Latihan 1
import java.util.Scanner;

/*
* 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 Andy
*/
public class nilaigrade {
public static void main (String []args){
double nilai;
String nama;
String nilaiangka;
String nilaihuruf;
Scanner input = new Scanner (System.in);
System.out.println("Nama = ");
nama = input.nextLine();
System.out.println("Nilai =");
nilai= input.nextDouble();
if( nilai >= 100){
System.out.println("Selamat " + nama + ", Anda memperoleh Grade A");
}
else if(nilai >= 86){
System.out.println("Selamat " + nama + ", Anda memperoleh Grade A");
}
else if (nilai >= 85){
System.out.println("Selamat " + nama + ", Anda memperoleh Grade B");
}
else if (nilai >= 76){
System.out.println("Selamat " + nama + ", Anda memperoleh Grade B");
}
else if (nilai >= 75){
System.out.println("Selamat " + nama + ",Anda memperoleh Grade C");
}
else if (nilai >= 61){
System.out.println("Selamat " + nama + ", Anda memperoleh Grade C");
}
else if (nilai >= 60){
System.out.println("Selamat " + nama + ", Anda memperoleh Grade D");
}
else if (nilai >= 50) {
System.out.println("Selamat " + nama + ", Anda memperoleh Grade D");
}
else if (nilai >= 50){
System.out.println("Selamat " + nama + ", Anda memperoleh Grade E");
}
else if (nilai >= 0){
System.out.println("Maaf " + nama + ", Anda Gagal");
}
}
}
Screenshot

2. Latihan 2
import java.util.Scanner;

/*
* 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 Andy
*/
public class beratbadan {
public static void main (String[]args){
double imt;
double bb = 1.60 * 1.60;
String nama, tinggibadan, beratbadan ;
Scanner input = new Scanner (System.in);
System.out.println("Nama =");
nama = input.nextLine();
System.out.println("TB =");
tinggibadan = input.nextLine();
System.out.println("BB =");
beratbadan = input.nextLine();
System.out.println("IMT =");
imt = input.nextDouble();
if (imt < 18.5){
System.out.println("kurus");
}
else if (imt == 18.5-24.9){
System.out.println("Normal");
}
else if (imt > 25-29.9){
System.out.println("Overweight");
}
else if ( imt >= 30){
System.out.println("Obesitas");
}
else if (bb >= 1.60){
System.out.println("");
}
}
}

3. Latihan3
import java.util.Scanner;

/*
* 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 Andy
*/
public class segitiga {
public static void main(String[] args) {
int a, b;
Scanner input = new Scanner(System.in);
System.out.println("=============================");
System.out.println("PROGRAM MENGHITUNG LUAS");
System.out.println("==========================");
System.out.println("1.Luas persegi panjang ");
System.out.println("2.Luas segitiga ");
System.out.println("==========================");
System.out.println("");
System.out.println("Masukkan Pilihan ANDA ");
System.out.print("Pilih luas : ");
int pilih = input.nextInt();
System.out.println("==========================");

switch (pilih) {
case 1:
System.out.print("Masukan Panjang : ");
int d = input.nextInt();
System.out.print("Masukan Lebar : ");
int c = input.nextInt();
int l = d * c;
System.out.println("");
System.out.println("==========================");
System.out.println("Luas Persegi panjang = " + l);
break;

case 2:
System.out.print("Masukan Alas : ");
double r = input.nextInt();
System.out.print("Masukan Tinggi : ");
double g = input.nextInt();
double h = (r * g) / 2;
System.out.println("==========================");
System.out.println("");
System.out.println("Luas Segitiga = " + h);
break;

}
}
}
Screenshot