Koding Program NetBeans
Penggunaan Fungsi If Bersarang dengan Tipe Data Integer dan String Pada Penginputan dan Output
import java.util.Scanner;
public class Agung {
public static void main(String[] args) {
Scanner kc=new Scanner (System.in);
System.out.print("Kode Customer = ");
int q =kc.nextInt();
if (q==15110672) {
System.out.println("Nama = Agung Lestari");
System.out.println("Alamat = Jalan Panglima Denai No 16 Medan");
System.out.println("No HP = 08786775894");
} else if (q == 15118998){
System.out.println("Nama = A.Emmanuel");
System.out.println("Alamat = Jalan Menteng Raya No 346a");
System.out.println("No HP = 081266778899");
} else if (q == 15113322){
System.out.println("Nama = Lucas Jovanka");
System.out.println("Alamat = Jalan Garu III");
System.out.println("No HP = 087867788998");
}
else {
System.out.println("Maaf Kode Salah");
}
Scanner kode=new Scanner (System.in);
System.out.print("Kode Barang = ");
String k=kode.nextLine();
Scanner merek=new Scanner (System.in);
System.out.print("Merek = ");
String m=merek.nextLine();
Scanner type=new Scanner (System.in);
System.out.print("Type = ");
String t=type.nextLine();
Scanner ram=new Scanner (System.in);
System.out.print("RAM = ");
String r=ram.nextLine();
Scanner internal=new Scanner (System.in);
System.out.print("Internal = ");
String i=internal.nextLine();
if (k.equals("S-01")){
if (m.equals("Samsung Galaxy")){
if(t.equals("S9")){
if (r.equals("4GB")){
if(i.equals("64GB")){
int hrg;
hrg = 10000000;
System.out.println("Harga = " +hrg);
}
}
}
}
} else if (m.equals("Samsung Galaxy")){
if(t.equals("S9+")){
if (r.equals("6GB")){
if(i.equals("256GB")){
int hrg;
hrg = 14000000;
System.out.println("Harga = " +hrg);
}
}
}
}
else if (k.equals("I-P1")){
if (m.equals("Apple")){
if(t.equals("Iphone 8")){
if (r.equals("2GB")){
if(i.equals("64GB")){
int hrg;
hrg = 91000000;
System.out.println("Harga = " +hrg);
}
}
}
}
} else if (m.equals("Apple")){
if(t.equals("Iphone 8+")){
if (r.equals("3GB")){
if(i.equals("64GB")){
int hrg;
hrg = 12500000;
System.out.println("Harga = " +hrg);
}
}
}
}
else if (k.equals("SZ-EX")){
if (m.equals("Sony Experia")){
if(t.equals("Z")){
if (r.equals("3GB")){
if(i.equals("11.8GB")){
int hrg ;
hrg = 70000000;
System.out.println("Harga = " +hrg);
}
}
}
}
} else if (m.equals("Sony Experia")){
if(t.equals("Z Ultra")){
if (r.equals("2GB")){
if(i.equals("11GB")){
int hrg;
hrg = 32500000;
System.out.println("Harga = " +hrg);
}
}
}
}
Scanner jm=new Scanner (System.in);
System.out.print("Jumlah Pembelian = ");
int j=jm.nextInt();
if(t.equals("S9")){
int th;
int hrg;
hrg = 10000000;
th = j*hrg;
if (j==2){
double d;
d=0.01*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==3){
double d;
d=0.02*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
}
else if (j==4){
double d;
d=0.03*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==5){
double d;
d=0.04*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
}
else if(t.equals("S9+")){
int th;
int hrg;
hrg = 14000000;
th = j*hrg;
System.out.println("Harga = " +th);
if (j==2){
double d;
d=0.01*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==3){
double d;
d=0.02*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
}
else if (j==4){
double d;
d=0.03*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==5){
double d;
d=0.04*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
}
else if(t.equals("Iphone 8")){
int th;
int hrg;
hrg = 91000000;
th = j*hrg;
System.out.println("Harga = " +th);
if (j==2){
double d;
d=0.01*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==3){
double d;
d=0.02*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
}
else if (j==4){
double d;
d=0.03*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==5){
double d;
d=0.04*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
}
else if(t.equals("Iphone 8+")){
int th;
int hrg;
hrg = 21500000;
th = j*hrg;
System.out.println("Harga = " +th);
if (j==2){
double d;
d=0.01*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==3){
double d;
d=0.02*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
}
else if (j==4){
double d;
d=0.03*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==5){
double d;
d=0.04*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
}
else if(t.equals("Z")){
int th;
int hrg;
hrg = 70000000;
th = j*hrg;
System.out.println("Harga = " +th);
if (j==2){
double d;
d=0.01*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==3){
double d;
d=0.02*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
}
else if (j==4){
double d;
d=0.03*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==5){
double d;
d=0.04*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
}
else if(t.equals("Z Ultra")){
int th;
int hrg;
hrg = 32500000;
th = j*hrg;
System.out.println("Harga = " +th);
if (j==2){
double d;
d=0.01*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==3){
double d;
d=0.02*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
}
else if (j==4){
double d;
d=0.03*th;
double tb;
tb = th-d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
else if (j==5){
double d;
d=0.04*th;
double tb;
tb = th - d;
System.out.println("Total Harga = "+th);
System.out.println("Discount = "+d);
System.out.println("Total Bayar = "+tb);
}
}
}
}
Gambar Di bawah ini akan memaparkan bagian input dan output :
Tidak ada komentar:
Posting Komentar