Advertisement
belamarsha

Untitled

Oct 24th, 2019
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class IDelivery
  3. {
  4. private String nama;
  5. private String barang;
  6. private int hargaBarang;
  7. private int jumlahBarang;
  8. private int kodeBarang;
  9. private String alamat;
  10. private String noHP;
  11. Scanner scan = new Scanner(System.in);
  12.  
  13. public void bayarIDelivery()
  14. {
  15. System.out.println("Masukkan Nama Pemesan :");
  16. nama = scan.next();
  17. System.out.println("\n");
  18. System.out.println("Masukkan Nomor HP :");
  19. noHP = scan.next();
  20. System.out.println("\n");
  21. System.out.println("Masukkan Alamat Pengiriman :");
  22. alamat = scan.nextLine();
  23. System.out.println("\n");
  24.  
  25. System.out.println("Pilih Barang");
  26. System.out.println("");
  27. System.out.println("1. AQUA GALON (18000)");
  28. System.out.println("2. GAS (20000)");
  29. System.out.println("3. AQUA GELAS KARDUS (20000)");
  30.  
  31. kodeBarang = scan.nextInt();
  32.  
  33. switch(kodeBarang)
  34. {
  35. case 1:
  36. barang = "AQUA GALON";
  37. hargaBarang = 18000;
  38. break;
  39. case 2:
  40. barang = "GAS";
  41. hargaBarang = 20000;
  42. break;
  43. case 3:
  44. barang = "AQUA GELAS KARDUS";
  45. hargaBarang = 30000;
  46. break;
  47. }
  48.  
  49. System.out.println("Masukkan Jumlah Barang");
  50. jumlahBarang = scan.nextInt();
  51. hitungHarga();
  52. printNota();
  53. }
  54.  
  55. public void hitungHarga()
  56. {
  57. hargaBarang = hargaBarang * jumlahBarang;
  58. }
  59.  
  60. public void printNota()
  61. {
  62. System.out.println("\n");
  63. System.out.println("I-Kios");
  64. System.out.println("IDelivery");
  65. System.out.println("Nama Pemesan : " + nama);
  66. System.out.println("Nomor HP : " + noHP );
  67. System.out.println("Alamat : " + alamat);
  68. System.out.println("Nama Barang : " + barang);
  69. System.out.println("Jumlah Barang : " + jumlahBarang);
  70. System.out.println("Harga : " + hargaBarang);
  71. System.out.println("\n");
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement