Koding Program NetBeans
Penggunaan IF Jamak pada Tipe Data Integer dan String
import java.util.Scanner;
package pertemuan;
import java.util.Scanner;
public class Pertemuan {
public static void main(String[] args) {
Scanner NPM=new Scanner (System.in);
System.out.print("NPM = ");
int x =NPM.nextInt();
if (x == 15110672) {
System.out.println("Nama = Agung Lestari");
} else if (x == 15118998){
System.out.println("Nama = Lala");
} else if (x == 15113322){
System.out.println("Nama = Lili");
} else if (x == 15111122){
System.out.println("Nama = Lulu");
}else if (x == 15110022){
System.out.println("Nama = Hehe");
}
else {
System.out.println("NPM Salah");
}
Scanner Jenjang=new Scanner(System.in);
System.out.print("Jenjang = ");
String jenjang = Jenjang.nextLine();
if (jenjang.equals("S1")){
System.out.println("Jurusan = Teknik Informatika");
} else if (jenjang.equals("D3")){
System.out.println("Jurusan = Manajemen Informatika");
} else{
System.out.println("Jenjang Salah");
}
Scanner Konsentrasi=new Scanner(System.in);
System.out.print("Konsentrasi = ");
String konsentrasi = Konsentrasi.nextLine();
Scanner NH=new Scanner(System.in);
System.out.print("Nilai Hadir = ");
int nh = NH.nextInt();
double nilai_hadir ;
nilai_hadir = 0.1 * nh ;
Scanner NG=new Scanner(System.in);
System.out.print("Nilai Tugas= ");
int ng = NG.nextInt();
double nilai_tugas ;
nilai_tugas = 0.2 * ng ;
Scanner NT=new Scanner(System.in);
System.out.print("Nilai UTS = ");
int nt = NT.nextInt();
double nilai_uts ;
nilai_uts = 0.3 * nt;
Scanner NA=new Scanner(System.in);
System.out.print("Nilai UAS = ");
int na = NA.nextInt();
double nilai_uas ;
nilai_uas = 0.4 * na;
double total_nilai = nilai_hadir + nilai_tugas + nilai_uts + nilai_uas;
System.out.println ("Total Nilai =" +total_nilai);
if (total_nilai > 90) {
System.out.println("Nilai Huruf = A ");
} else if (total_nilai > 85 ) {
System.out.println("Nilai Huruf = B+");
} else if (total_nilai > 80 ) {
System.out.println("Nilai Huruf = B");
} else if (total_nilai > 75 ) {
System.out.println("Nilai Huruf = C+");
}else if (total_nilai > 70 ) {
System.out.println("Nilai Huruf = C");
}else if (total_nilai > 55 ) {
System.out.println("Nilai Huruf = D");
} else if (total_nilai < 55 ) {
System.out.println("Nilai Huruf = E");
}
}
}
Scanner NPM=new Scanner (System.in);
System.out.print("NPM = ");
int x =NPM.nextInt();
if (x == 15110672) {
System.out.println("Nama = Agung Lestari");
} else if (x == 15118998){
System.out.println("Nama = Lala");
} else if (x == 15113322){
System.out.println("Nama = Lili");
} else if (x == 15111122){
System.out.println("Nama = Lulu");
}else if (x == 15110022){
System.out.println("Nama = Hehe");
}
else {
System.out.println("NPM Salah");
}
Scanner Jenjang=new Scanner(System.in);
System.out.print("Jenjang = ");
String jenjang = Jenjang.nextLine();
if (jenjang.equals("S1")){
System.out.println("Jurusan = Teknik Informatika");
} else if (jenjang.equals("D3")){
System.out.println("Jurusan = Manajemen Informatika");
} else{
System.out.println("Jenjang Salah");
}
Scanner Konsentrasi=new Scanner(System.in);
System.out.print("Konsentrasi = ");
String konsentrasi = Konsentrasi.nextLine();
Scanner NH=new Scanner(System.in);
System.out.print("Nilai Hadir = ");
int nh = NH.nextInt();
double nilai_hadir ;
nilai_hadir = 0.1 * nh ;
Scanner NG=new Scanner(System.in);
System.out.print("Nilai Tugas= ");
int ng = NG.nextInt();
double nilai_tugas ;
nilai_tugas = 0.2 * ng ;
Scanner NT=new Scanner(System.in);
System.out.print("Nilai UTS = ");
int nt = NT.nextInt();
double nilai_uts ;
nilai_uts = 0.3 * nt;
Scanner NA=new Scanner(System.in);
System.out.print("Nilai UAS = ");
int na = NA.nextInt();
double nilai_uas ;
nilai_uas = 0.4 * na;
double total_nilai = nilai_hadir + nilai_tugas + nilai_uts + nilai_uas;
System.out.println ("Total Nilai =" +total_nilai);
if (total_nilai > 90) {
System.out.println("Nilai Huruf = A ");
} else if (total_nilai > 85 ) {
System.out.println("Nilai Huruf = B+");
} else if (total_nilai > 80 ) {
System.out.println("Nilai Huruf = B");
} else if (total_nilai > 75 ) {
System.out.println("Nilai Huruf = C+");
}else if (total_nilai > 70 ) {
System.out.println("Nilai Huruf = C");
}else if (total_nilai > 55 ) {
System.out.println("Nilai Huruf = D");
} else if (total_nilai < 55 ) {
System.out.println("Nilai Huruf = E");
}
}
}
Seperti pada gambar di bawah ini akan dipaparkan bagian mana yang di input dan bagian mana yang menjadi output :
Tidak ada komentar:
Posting Komentar