Koding Program Netbeans
Penggunaan Case Bersarang dengan Tipe Data Integer dan String pada Penginputan data dan Output
import java.util.Scanner;
public class AgungLestari {
public static void main(String[] args) {
Scanner koco=new Scanner (System.in);
System.out.print("Kode Costumer=");
int kc=koco.nextInt();
switch (kc) {
case 15110672 :
System.out.println ("Nama = Agung Lestari");
System.out.println ("Alamat = Jalan Panglima Denai No 16");
System.out.println ("No HP = 08786775894");
break;
case 15110099:
System.out.println ("Nama = Haha");
System.out.println ("Alamat = Jalan Menteng Raya No 346a");
System.out.println ("No HP = 081266778899");
break;
case 15117766:
System.out.println ("Nama = Jojo");
System.out.println ("Alamat = Jalan Garu III");
System.out.println ("No HP = 08786779988");
default:
System.out.println ("Maaf Kode Salah");
break;
}
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();
switch (k){
case "S-01":
switch (m){
case "Samsung Galaxy":
switch (t){
case "S9":
switch (r){
case "4GB":
switch (i){
case "64GB":
int hrg;
hrg = 1000000;
System.out.println("Harga = "+hrg);
}
}
}
}
switch (m){
case "Samsung Galaxy":
switch (t){
case "S9+":
switch (r){
case "6GB":
switch (i){
case "256GB":
int hrg;
hrg = 1400000;
System.out.println("Harga = "+hrg);
break;
}
}
}
}
}
switch(k){
case "I-P1":
switch (m){
case "Apple":
switch (t){
case "Iphone 8":
switch (r){
case "2GB":
switch (i){
case "64GB":
int hrg;
hrg = 91000000;
System.out.println ("Harga = "+hrg);
break;
}
}
}
}
switch (m){
case "Apple":
switch (t){
case "Iphone 8+":
switch (r){
case "3GB":
switch (i){
case "64GB":
int hrg;
hrg = 12500000;
System.out.println ("Harga = "+hrg);
break;
}
}
}
}
}
switch(k){
case "SZ-EX":
switch (m){
case "Sony Experia":
switch (t){
case "Z":
switch (r){
case "3GB":
switch (i){
case "11.8GB":
int
hrg = 70000000;
System.out.println ("Harga = "+hrg);
break;
}
}
}
}
switch (m){
case "Sony Experia":
switch (t){
case "Z Ultra":
switch (r){
case "2GB":
switch (i){
case "11GB":
int hrg;
hrg = 32500000;
System.out.println ("Harga = "+hrg);
break;
}
}
}
}
}
Scanner jumpe=new Scanner (System.in);
System.out.print ("Jumlah Pembelian = ");
int j=jumpe.nextInt();
switch(t){
case "S9":
int th ;
int hrg;
hrg = 10000000;
th = j*hrg;
switch (j){
case 2:
double d;
double tb;
d = 0.01*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 3:
double d;
double tb;
d = 0.02*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 4:
double d;
double tb;
d = 0.03*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 5:
double d;
double tb;
d = 0.04*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
break;
}
switch(t){
case "S9+":
int th ;
int hrg;
hrg = 14000000;
th = j*hrg;
switch (j){
case 2:
double d;
double tb;
d = 0.01*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 3:
double d;
double tb;
d = 0.02*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 4:
double d;
double tb;
d = 0.03*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 5:
double d;
double tb;
d = 0.04*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
break;
}
switch(t){
case "Iphone 8":
int th ;
int hrg;
hrg = 91000000;
th = j*hrg;
switch (j){
case 2:
double d;
double tb;
d = 0.01*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 3:
double d;
double tb;
d = 0.02*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 4:
double d;
double tb;
d = 0.03*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 5:
double d;
double tb;
d = 0.04*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
break;
}
switch(t){
case "Iphone 8+":
int th ;
int hrg;
hrg = 12500000;
th = j*hrg;
switch (j){
case 2:
double d;
double tb;
d = 0.01*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 3:
double d;
double tb;
d = 0.02*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 4:
double d;
double tb;
d = 0.03*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 5:
double d;
double tb;
d = 0.04*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
break;
}
switch(t){
case "Z":
int th ;
int hrg = 70000000;
th = j*hrg;
switch (j){
case 2:
double d;
double tb;
d = 0.01*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 3:
double d;
double tb;
d = 0.02*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 4:
double d;
double tb;
d = 0.03*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 5:
double d;
double tb;
d = 0.04*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
break;
}
switch(t){
case "Z Ultra":
int th ;
int hrg;
hrg = 32500000;
th = j*hrg;
switch (j){
case 2:
double d;
double tb;
d = 0.01*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 3:
double d;
double tb;
d = 0.02*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 4:
double d;
double tb;
d = 0.03*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
switch (j){
case 5:
double d;
double tb;
d = 0.04*hrg;
tb = th-d ;
System.out.println ("Total Harga = "+th);
System.out.println ("Discount = "+d);
System.out.println ("Total Bayar = "+tb);
break;
}
break;
}
}
}
Maka akan tampil seperti gambar di bawah ini :
Tidak ada komentar:
Posting Komentar