Koding Program NetBeans Penggunaan Fungsi If Bersarang dengan Tipe Data Integer dan String Pada Penginputan dan Output
Dosen Pengampu : Fince Tinus Waruwu, S.Kom, M.Kom
package rosliana;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO code application logic here
Scanner kc=new Scanner (System.in);
System.out.print("Kode Customer = ");
int q =kc.nextInt();
if (q==15110046) {
System.out.println("Nama = Rosliana Siregar");
System.out.println("Alamat = Tanjung Morawa");
System.out.println("No HP = 081375097908");
} else if (q == 15110707){
System.out.println("Nama = Zovi Darma Putra");
System.out.println("Alamat = Jalan Limau Manis");
System.out.println("No HP = 081362869118");
} else if (q == 15112457){
System.out.println("Nama = Nuriani");
System.out.println("Alamat = Lubuk Pakam");
System.out.println("No HP = 085297559159");
}
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);
}
}
}
}
package rosliana;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO code application logic here
Scanner kc=new Scanner (System.in);
System.out.print("Kode Customer = ");
int q =kc.nextInt();
if (q==15110046) {
System.out.println("Nama = Rosliana Siregar");
System.out.println("Alamat = Tanjung Morawa");
System.out.println("No HP = 081375097908");
} else if (q == 15110707){
System.out.println("Nama = Zovi Darma Putra");
System.out.println("Alamat = Jalan Limau Manis");
System.out.println("No HP = 081362869118");
} else if (q == 15112457){
System.out.println("Nama = Nuriani");
System.out.println("Alamat = Lubuk Pakam");
System.out.println("No HP = 085297559159");
}
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);
}
}
}
}
Komentar
Posting Komentar