Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream.h>
  3. #include <stdio.h>
  4.  
  5. void main()
  6. {
  7.  
  8. char nama[30], kode[10], keterangan[20];
  9. int ket, pemakaian, totalkriteria, total, bayar, kembalian;
  10.  
  11. cout<<"\n\t\t\t\t\t\tTugas Switch Case"<<endl;
  12. cout<<"\n\tKode Pelanggan : ";
  13. cin>>kode;
  14. cout<<"\tNama Pelanggan : ";
  15. gets(nama);
  16. cout<<"\tKeterangan Pelanggan [1..3] : ";
  17. cin>>ket;
  18. cout<<"================================"<<endl;
  19.  
  20. if(ket > 3){
  21. cout<<"Salah memasukkan kode";
  22. } else {
  23.  
  24. switch(ket)
  25. {
  26.  
  27. case 1 :
  28. cout<<"Rumah"<<endl;
  29. cout<<"Pemakaian : ";
  30. cin>>pemakaian;
  31. total = pemakaian * 1200;
  32. if(total >= 100000) {
  33. totalkriteria = total - (total * 0.07) ; }
  34. else if (total >= 50000) {
  35. totalkriteria = total - (total * 0.02) ; }
  36.  
  37. else {
  38. totalkriteria = total; }
  39. break;
  40.  
  41. case 2 :
  42. cout<<"Ruko"<<endl;
  43. cout<<"Pemakaian : ";
  44. cin>>pemakaian;
  45. total = pemakaian * 2000;
  46. if(total >= 100000) {
  47. totalkriteria = total - (total * 0.10) ; }
  48. else if (total >= 50000) {
  49. totalkriteria = total - (total * 0.05) ; }
  50. else {
  51. totalkriteria = total - (total * 0.03) ; }
  52. break;
  53.  
  54. case 3 :
  55. cout<<"Perusahaan"<<endl;
  56. cout<<"Pemakaian : ";
  57. cin>>pemakaian;
  58. total = pemakaian * 35000;
  59. if (total >= 100000) {
  60. totalkriteria = total - (total * 0.12) ; }
  61. else if (total >= 50000) {
  62. totalkriteria = total - (total * 0.07) ; }
  63. else {
  64. totalkriteria = total - (total * 0.05) ; }
  65. break;
  66. default:
  67. break;
  68.  
  69. }
  70. cout<<"Jumlah Bayar(sebelum diskon) : "<<total<<endl;
  71. cout<<"Jumlah Bayar(sesudah diskon) : "<<totalkriteria<<endl;
  72. cout<<"Masukan Jumlah Bayar : ";
  73. cin>>bayar;
  74. kembalian = bayar - totalkriteria;
  75. cout<<"Kembalian Pelanggan : "<<kembalian;
  76. }
  77.  
  78. getch();
  79.  
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement